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