reveil/api/quotes.go

48 lines
894 B
Go

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"`
}