feat: add all route
This commit is contained in:
@@ -5,6 +5,8 @@ services:
|
||||
image: postgres:10-alpine
|
||||
environment:
|
||||
- POSTGRES_DB=hamster_tycoon
|
||||
- POSTGRES_PASSWORD=hamster_tycoon
|
||||
- POSTGRES_HOST_AUTH_METHOD=trust
|
||||
ports:
|
||||
- "5432"
|
||||
healthcheck:
|
||||
|
||||
@@ -61,15 +61,37 @@ func NewRouter(config *Config) *gin.Engine {
|
||||
public := router.Group("/")
|
||||
public.Handle(http.MethodGet, "/_health", hc.GetHealth)
|
||||
|
||||
public.Handle("LOGIN", "/users", hc.ConnectUser)
|
||||
// start: user routes
|
||||
public.Handle(http.MethodGet, "/users", hc.GetAllUsers)
|
||||
public.Handle(http.MethodPost, "/users", hc.CreateUser)
|
||||
public.Handle(http.MethodGet, "/users/:id", hc.GetUser)
|
||||
public.Handle(http.MethodPut, "/users/:id", hc.UpdateUser)
|
||||
public.Handle(http.MethodDelete, "/users/:id", hc.DeleteUser)
|
||||
userRoute := public.Group("/users")
|
||||
userRoute.Handle("LOGIN", "", hc.ConnectUser)
|
||||
userRoute.Handle(http.MethodPost, "", hc.CreateUser)
|
||||
|
||||
securedUserRoute := userRoute.Group("")
|
||||
//TODO add secure auth
|
||||
securedUserRoute.Handle(http.MethodGet, "", hc.GetAllUsers)
|
||||
securedUserRoute.Handle(http.MethodGet, "/:userId", hc.GetUser)
|
||||
securedUserRoute.Handle(http.MethodPut, "/:userId", hc.UpdateUser)
|
||||
securedUserRoute.Handle(http.MethodDelete, "/:userId", hc.DeleteUser)
|
||||
// end: user routes
|
||||
|
||||
gameRoute := securedUserRoute.Group("/:userId/games")
|
||||
gameRoute.Handle(http.MethodGet, "", nil)
|
||||
gameRoute.Handle(http.MethodGet, "/:gameId", nil)
|
||||
gameRoute.Handle(http.MethodPost, "/:gameId", nil)
|
||||
gameRoute.Handle(http.MethodPut, "/:gameId",nil)
|
||||
gameRoute.Handle(http.MethodGet, "/:gameId/hamsters",nil)
|
||||
|
||||
cageRoute := gameRoute.Group("/:gameId/cages")
|
||||
cageRoute.Handle(http.MethodGet, "",nil)
|
||||
cageRoute.Handle(http.MethodGet, "/:cageId", nil)
|
||||
cageRoute.Handle(http.MethodPost, "/:cageId", nil)
|
||||
cageRoute.Handle(http.MethodPut, "/:cageId", nil)
|
||||
|
||||
hamsterRoute := cageRoute.Group("/:cageId/hamster")
|
||||
hamsterRoute.Handle(http.MethodGet, "",nil)
|
||||
hamsterRoute.Handle(http.MethodGet, "/:cageId", nil)
|
||||
hamsterRoute.Handle(http.MethodPost, "/:cageId", nil)
|
||||
hamsterRoute.Handle(http.MethodPut, "/:cageId", nil)
|
||||
|
||||
return router
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user