This commit is contained in:
nemunaire 2022-10-02 23:24:53 +02:00
commit a9be05854c
11 changed files with 331 additions and 12 deletions

47
api/quotes.go Normal file
View file

@ -0,0 +1,47 @@
package api
import (
"net/http"
"github.com/gin-gonic/gin"
"git.nemunai.re/nemunaire/reveil/config"
)
func declareQuotesRoutes(cfg *config.Config, router *gin.RouterGroup) {
router.GET("/quoteoftheday", func(c *gin.Context) {
})
router.GET("/quotes", func(c *gin.Context) {
})
router.POST("/quotes", func(c *gin.Context) {
})
quotesRoutes := router.Group("/quotes/:qid")
quotesRoutes.Use(quoteHandler)
quotesRoutes.GET("", func(c *gin.Context) {
c.JSON(http.StatusOK, c.MustGet("quote"))
})
quotesRoutes.PUT("", func(c *gin.Context) {
c.JSON(http.StatusOK, c.MustGet("quote"))
})
quotesRoutes.DELETE("", func(c *gin.Context) {
c.JSON(http.StatusOK, c.MustGet("quote"))
})
}
func quoteHandler(c *gin.Context) {
c.Set("quote", nil)
c.Next()
}
type Quote struct {
Id int `json:"id"`
Content string `json:"content"`
Author string `json:"author"`
}