Mock API
This commit is contained in:
parent
be8ff3466a
commit
a9be05854c
11 changed files with 331 additions and 12 deletions
37
api/actions.go
Normal file
37
api/actions.go
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
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()
|
||||
}
|
||||
86
api/alarms.go
Normal file
86
api/alarms.go
Normal file
|
|
@ -0,0 +1,86 @@
|
|||
package api
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
|
||||
"git.nemunai.re/nemunaire/reveil/config"
|
||||
)
|
||||
|
||||
func declareAlarmsRoutes(cfg *config.Config, router *gin.RouterGroup) {
|
||||
router.GET("/alarms/next", func(c *gin.Context) {
|
||||
|
||||
})
|
||||
|
||||
router.POST("/alarms", func(c *gin.Context) {
|
||||
|
||||
})
|
||||
|
||||
router.GET("/alarms/manuals", func(c *gin.Context) {
|
||||
|
||||
})
|
||||
router.GET("/alarms/usuals", func(c *gin.Context) {
|
||||
|
||||
})
|
||||
router.GET("/alarms/excepts", func(c *gin.Context) {
|
||||
|
||||
})
|
||||
|
||||
manualAlarmsRoutes := router.Group("/alarms/manuals/:aid")
|
||||
manualAlarmsRoutes.Use(manualAlarmHandler)
|
||||
|
||||
manualAlarmsRoutes.GET("", func(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, c.MustGet("alarm"))
|
||||
})
|
||||
manualAlarmsRoutes.PUT("", func(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, c.MustGet("alarm"))
|
||||
})
|
||||
manualAlarmsRoutes.DELETE("", func(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, c.MustGet("alarm"))
|
||||
})
|
||||
|
||||
usualAlarmsRoutes := router.Group("/alarms/usuals/:aid")
|
||||
usualAlarmsRoutes.Use(usualAlarmHandler)
|
||||
|
||||
usualAlarmsRoutes.GET("", func(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, c.MustGet("alarm"))
|
||||
})
|
||||
usualAlarmsRoutes.PUT("", func(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, c.MustGet("alarm"))
|
||||
})
|
||||
usualAlarmsRoutes.DELETE("", func(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, c.MustGet("alarm"))
|
||||
})
|
||||
|
||||
exceptAlarmsRoutes := router.Group("/alarms/excepts/:aid")
|
||||
exceptAlarmsRoutes.Use(exceptAlarmHandler)
|
||||
|
||||
exceptAlarmsRoutes.GET("", func(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, c.MustGet("alarm"))
|
||||
})
|
||||
exceptAlarmsRoutes.PUT("", func(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, c.MustGet("alarm"))
|
||||
})
|
||||
exceptAlarmsRoutes.DELETE("", func(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, c.MustGet("alarm"))
|
||||
})
|
||||
}
|
||||
|
||||
func manualAlarmHandler(c *gin.Context) {
|
||||
c.Set("alarm", nil)
|
||||
|
||||
c.Next()
|
||||
}
|
||||
|
||||
func usualAlarmHandler(c *gin.Context) {
|
||||
c.Set("alarm", nil)
|
||||
|
||||
c.Next()
|
||||
}
|
||||
|
||||
func exceptAlarmHandler(c *gin.Context) {
|
||||
c.Set("alarm", nil)
|
||||
|
||||
c.Next()
|
||||
}
|
||||
37
api/gongs.go
Normal file
37
api/gongs.go
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
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()
|
||||
}
|
||||
13
api/history.go
Normal file
13
api/history.go
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
package api
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
|
||||
"git.nemunai.re/nemunaire/reveil/config"
|
||||
)
|
||||
|
||||
func declareHistoryRoutes(cfg *config.Config, router *gin.RouterGroup) {
|
||||
router.GET("/stats", func(c *gin.Context) {
|
||||
|
||||
})
|
||||
}
|
||||
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"`
|
||||
}
|
||||
|
|
@ -1,23 +1,20 @@
|
|||
package api
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
|
||||
"git.nemunai.re/nemunaire/reveil/config"
|
||||
//"git.nemunai.re/nemunaire/reveil/model"
|
||||
)
|
||||
|
||||
func DeclareRoutes(router *gin.Engine, cfg *config.Config) {
|
||||
apiRoutes := router.Group("/api")
|
||||
|
||||
apiRoutes.GET("/test", func(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, "test")
|
||||
})
|
||||
|
||||
//declareFilesRoutes(cfg, apiAuthRoutes)
|
||||
//declareIngredientsRoutes(cfg, apiAuthRoutes)
|
||||
//declareRecipesRoutes(cfg, apiAuthRoutes)
|
||||
//declareUsersRoutes(cfg, apiAuthRoutes)
|
||||
declareActionsRoutes(cfg, apiRoutes)
|
||||
declareAlarmsRoutes(cfg, apiRoutes)
|
||||
declareGongsRoutes(cfg, apiRoutes)
|
||||
declareHistoryRoutes(cfg, apiRoutes)
|
||||
declareQuotesRoutes(cfg, apiRoutes)
|
||||
declareRoutinesRoutes(cfg, apiRoutes)
|
||||
declareTracksRoutes(cfg, apiRoutes)
|
||||
declareSettingsRoutes(cfg, apiRoutes)
|
||||
}
|
||||
|
|
|
|||
37
api/routines.go
Normal file
37
api/routines.go
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
package api
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
|
||||
"git.nemunai.re/nemunaire/reveil/config"
|
||||
)
|
||||
|
||||
func declareRoutinesRoutes(cfg *config.Config, router *gin.RouterGroup) {
|
||||
router.GET("/routines", func(c *gin.Context) {
|
||||
|
||||
})
|
||||
router.POST("/routines", func(c *gin.Context) {
|
||||
|
||||
})
|
||||
|
||||
routinesRoutes := router.Group("/routines/:gid")
|
||||
routinesRoutes.Use(routineHandler)
|
||||
|
||||
routinesRoutes.GET("", func(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, c.MustGet("routine"))
|
||||
})
|
||||
routinesRoutes.PUT("", func(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, c.MustGet("routine"))
|
||||
})
|
||||
routinesRoutes.DELETE("", func(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, c.MustGet("routine"))
|
||||
})
|
||||
}
|
||||
|
||||
func routineHandler(c *gin.Context) {
|
||||
c.Set("routine", nil)
|
||||
|
||||
c.Next()
|
||||
}
|
||||
16
api/settings.go
Normal file
16
api/settings.go
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
package api
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
|
||||
"git.nemunai.re/nemunaire/reveil/config"
|
||||
)
|
||||
|
||||
func declareSettingsRoutes(cfg *config.Config, router *gin.RouterGroup) {
|
||||
router.GET("/settings", func(c *gin.Context) {
|
||||
|
||||
})
|
||||
router.PUT("/settings", func(c *gin.Context) {
|
||||
|
||||
})
|
||||
}
|
||||
37
api/tracks.go
Normal file
37
api/tracks.go
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
package api
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
|
||||
"git.nemunai.re/nemunaire/reveil/config"
|
||||
)
|
||||
|
||||
func declareTracksRoutes(cfg *config.Config, router *gin.RouterGroup) {
|
||||
router.GET("/tracks", func(c *gin.Context) {
|
||||
|
||||
})
|
||||
router.POST("/tracks", func(c *gin.Context) {
|
||||
|
||||
})
|
||||
|
||||
tracksRoutes := router.Group("/tracks/:tid")
|
||||
tracksRoutes.Use(trackHandler)
|
||||
|
||||
tracksRoutes.GET("", func(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, c.MustGet("track"))
|
||||
})
|
||||
tracksRoutes.PUT("", func(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, c.MustGet("track"))
|
||||
})
|
||||
tracksRoutes.DELETE("", func(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, c.MustGet("track"))
|
||||
})
|
||||
}
|
||||
|
||||
func trackHandler(c *gin.Context) {
|
||||
c.Set("track", nil)
|
||||
|
||||
c.Next()
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue