Mock API
This commit is contained in:
parent
be8ff3466a
commit
a9be05854c
11 changed files with 331 additions and 12 deletions
37
api/actions.go
Normal file
37
api/actions.go
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
package api
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
|
||||
"git.nemunai.re/nemunaire/reveil/config"
|
||||
)
|
||||
|
||||
func declareActionsRoutes(cfg *config.Config, router *gin.RouterGroup) {
|
||||
router.GET("/actions", func(c *gin.Context) {
|
||||
|
||||
})
|
||||
router.POST("/actions", func(c *gin.Context) {
|
||||
|
||||
})
|
||||
|
||||
actionsRoutes := router.Group("/actions/:gid")
|
||||
actionsRoutes.Use(actionHandler)
|
||||
|
||||
actionsRoutes.GET("", func(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, c.MustGet("action"))
|
||||
})
|
||||
actionsRoutes.PUT("", func(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, c.MustGet("action"))
|
||||
})
|
||||
actionsRoutes.DELETE("", func(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, c.MustGet("action"))
|
||||
})
|
||||
}
|
||||
|
||||
func actionHandler(c *gin.Context) {
|
||||
c.Set("action", nil)
|
||||
|
||||
c.Next()
|
||||
}
|
||||
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()
|
||||
}
|
||||
37
api/gongs.go
Normal file
37
api/gongs.go
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
package api
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
|
||||
"git.nemunai.re/nemunaire/reveil/config"
|
||||
)
|
||||
|
||||
func declareGongsRoutes(cfg *config.Config, router *gin.RouterGroup) {
|
||||
router.GET("/gongs", func(c *gin.Context) {
|
||||
|
||||
})
|
||||
router.POST("/gongs", func(c *gin.Context) {
|
||||
|
||||
})
|
||||
|
||||
gongsRoutes := router.Group("/gongs/:gid")
|
||||
gongsRoutes.Use(gongHandler)
|
||||
|
||||
gongsRoutes.GET("", func(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, c.MustGet("gong"))
|
||||
})
|
||||
gongsRoutes.PUT("", func(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, c.MustGet("gong"))
|
||||
})
|
||||
gongsRoutes.DELETE("", func(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, c.MustGet("gong"))
|
||||
})
|
||||
}
|
||||
|
||||
func gongHandler(c *gin.Context) {
|
||||
c.Set("gong", nil)
|
||||
|
||||
c.Next()
|
||||
}
|
||||
13
api/history.go
Normal file
13
api/history.go
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
package api
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
|
||||
"git.nemunai.re/nemunaire/reveil/config"
|
||||