Init
This commit is contained in:
commit
f90fdc0598
99 changed files with 15260 additions and 0 deletions
62
api/router.go
Normal file
62
api/router.go
Normal file
|
@ -0,0 +1,62 @@
|
|||
package api
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
func (a *Api) SetupRouter() {
|
||||
api := a.Router.Group("/api")
|
||||
{
|
||||
tableGroup := api.Group("/tables")
|
||||
{
|
||||
tableGroup.GET("", a.getTables)
|
||||
tableGroup.POST("", a.createTable)
|
||||
tableGroup.DELETE("", a.deleteTable)
|
||||
}
|
||||
orderGroup := api.Group("/orders")
|
||||
{
|
||||
orderGroup.GET("", a.getOrders)
|
||||
orderGroup.POST("", a.createOrder)
|
||||
orderGroup.DELETE("", a.deleteOrder)
|
||||
orderGroup.PUT("", a.updateOrder)
|
||||
orderGroup.GET("/ws", a.serveWs)
|
||||
orderItemGroup := orderGroup.Group("/items")
|
||||
{
|
||||
orderItemGroup.GET("", a.getOrderItems)
|
||||
orderItemGroup.POST("", a.createOrderItem)
|
||||
orderItemGroup.PUT("", a.updateOrderItem)
|
||||
orderItemGroup.DELETE("/:id", a.deleteOrderItem)
|
||||
}
|
||||
}
|
||||
billGroup := api.Group("/bills")
|
||||
{
|
||||
billGroup.GET("", a.getBills)
|
||||
billGroup.POST("", a.createBill)
|
||||
billGroup.DELETE("/:id", a.deleteBill)
|
||||
billItemGroup := billGroup.Group("/items")
|
||||
{
|
||||
billItemGroup.GET("", a.getBillItems)
|
||||
}
|
||||
}
|
||||
userGroup := api.Group("/users")
|
||||
{
|
||||
userGroup.GET("/:username", a.getUser)
|
||||
userGroup.PUT("", a.updateUser)
|
||||
}
|
||||
health := api.Group("/health")
|
||||
{
|
||||
health.Use(authHeader())
|
||||
health.GET("", func(c *gin.Context) {
|
||||
c.Status(http.StatusOK)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
a.Router.NoRoute(func(c *gin.Context) {
|
||||
c.HTML(http.StatusOK, "index.html", nil)
|
||||
})
|
||||
logrus.WithField("amount", len(a.Router.Routes())).Debug("Routes initialized")
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue