feat: add all route

This commit is contained in:
Jeffrey Duroyon
2020-05-10 01:13:05 +02:00
parent afdb2e2d0e
commit 520eeba8fd
2 changed files with 31 additions and 7 deletions

View File

@@ -5,6 +5,8 @@ services:
image: postgres:10-alpine image: postgres:10-alpine
environment: environment:
- POSTGRES_DB=hamster_tycoon - POSTGRES_DB=hamster_tycoon
- POSTGRES_PASSWORD=hamster_tycoon
- POSTGRES_HOST_AUTH_METHOD=trust
ports: ports:
- "5432" - "5432"
healthcheck: healthcheck:

View File

@@ -61,15 +61,37 @@ func NewRouter(config *Config) *gin.Engine {
public := router.Group("/") public := router.Group("/")
public.Handle(http.MethodGet, "/_health", hc.GetHealth) public.Handle(http.MethodGet, "/_health", hc.GetHealth)
public.Handle("LOGIN", "/users", hc.ConnectUser) userRoute := public.Group("/users")
// start: user routes userRoute.Handle("LOGIN", "", hc.ConnectUser)
public.Handle(http.MethodGet, "/users", hc.GetAllUsers) userRoute.Handle(http.MethodPost, "", hc.CreateUser)
public.Handle(http.MethodPost, "/users", hc.CreateUser)
public.Handle(http.MethodGet, "/users/:id", hc.GetUser) securedUserRoute := userRoute.Group("")
public.Handle(http.MethodPut, "/users/:id", hc.UpdateUser) //TODO add secure auth
public.Handle(http.MethodDelete, "/users/:id", hc.DeleteUser) 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 // 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 return router
} }