Mock API
This commit is contained in:
parent
be8ff3466a
commit
a9be05854c
11 changed files with 331 additions and 12 deletions
47
api/quotes.go
Normal file
47
api/quotes.go
Normal 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"`
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue