Mock API
This commit is contained in:
parent
be8ff3466a
commit
a9be05854c
11 changed files with 331 additions and 12 deletions
86
api/alarms.go
Normal file
86
api/alarms.go
Normal file
|
|
@ -0,0 +1,86 @@
|
|||
package api
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
|
||||
"git.nemunai.re/nemunaire/reveil/config"
|
||||
)
|
||||
|
||||
func declareAlarmsRoutes(cfg *config.Config, router *gin.RouterGroup) {
|
||||
router.GET("/alarms/next", func(c *gin.Context) {
|
||||
|
||||
})
|
||||
|
||||
router.POST("/alarms", func(c *gin.Context) {
|
||||
|
||||
})
|
||||
|
||||
router.GET("/alarms/manuals", func(c *gin.Context) {
|
||||
|
||||
})
|
||||
router.GET("/alarms/usuals", func(c *gin.Context) {
|
||||
|
||||
})
|
||||
router.GET("/alarms/excepts", func(c *gin.Context) {
|
||||
|
||||
})
|
||||
|
||||
manualAlarmsRoutes := router.Group("/alarms/manuals/:aid")
|
||||
manualAlarmsRoutes.Use(manualAlarmHandler)
|
||||
|
||||
manualAlarmsRoutes.GET("", func(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, c.MustGet("alarm"))
|
||||
})
|
||||
manualAlarmsRoutes.PUT("", func(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, c.MustGet("alarm"))
|
||||
})
|
||||
manualAlarmsRoutes.DELETE("", func(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, c.MustGet("alarm"))
|
||||
})
|
||||
|
||||
usualAlarmsRoutes := router.Group("/alarms/usuals/:aid")
|
||||
usualAlarmsRoutes.Use(usualAlarmHandler)
|
||||
|
||||
usualAlarmsRoutes.GET("", func(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, c.MustGet("alarm"))
|
||||
})
|
||||
usualAlarmsRoutes.PUT("", func(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, c.MustGet("alarm"))
|
||||
})
|
||||
usualAlarmsRoutes.DELETE("", func(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, c.MustGet("alarm"))
|
||||
})
|
||||
|
||||
exceptAlarmsRoutes := router.Group("/alarms/excepts/:aid")
|
||||
exceptAlarmsRoutes.Use(exceptAlarmHandler)
|
||||
|
||||
exceptAlarmsRoutes.GET("", func(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, c.MustGet("alarm"))
|
||||
})
|
||||
exceptAlarmsRoutes.PUT("", func(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, c.MustGet("alarm"))
|
||||
})
|
||||
exceptAlarmsRoutes.DELETE("", func(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, c.MustGet("alarm"))
|
||||
})
|
||||
}
|
||||
|
||||
func manualAlarmHandler(c *gin.Context) {
|
||||
c.Set("alarm", nil)
|
||||
|
||||
c.Next()
|
||||
}
|
||||
|
||||
func usualAlarmHandler(c *gin.Context) {
|
||||
c.Set("alarm", nil)
|
||||
|
||||
c.Next()
|
||||
}
|
||||
|
||||
func exceptAlarmHandler(c *gin.Context) {
|
||||
c.Set("alarm", nil)
|
||||
|
||||
c.Next()
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue