38 lines
734 B
Go
38 lines
734 B
Go
|
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()
|
||
|
}
|