Skip to content

Commit

Permalink
rever router
Browse files Browse the repository at this point in the history
  • Loading branch information
abaldeweg authored Jan 2, 2025
1 parent 51fc64a commit b91306b
Show file tree
Hide file tree
Showing 2 changed files with 162 additions and 44 deletions.
84 changes: 42 additions & 42 deletions gateway/router/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,52 +260,52 @@ func Routes() *gin.Engine {
apiCorePublic.POST(`/reservation/new`, handleCoreAPI("/api/public/reservation/new"))
}

apiCoreReservation := apiCore.Group(`/api/reservation`)
{
apiCoreReservation.Use(func(c *gin.Context) {
if !authenticator(c) {
c.AbortWithStatusJSON(http.StatusUnauthorized, gin.H{"msg": "Unauthorized"})
return
}
c.Next()
})

apiCoreReservation.GET(`/list`, RoleMiddleware("ROLE_USER"), func(c *gin.Context) {
rc := controllers.NewReservationController(db)
rc.FindAll(c)
})
apiCoreReservation.GET(`/status`, RoleMiddleware("ROLE_USER"), func(c *gin.Context) {
rc := controllers.NewReservationController(db)
rc.ReservationStatus(c)
})
apiCoreReservation.GET(`/:id`, RoleMiddleware("ROLE_USER"), func(c *gin.Context) {
rc := controllers.NewReservationController(db)
rc.FindOne(c)
})
apiCoreReservation.POST(`/new`, RoleMiddleware("ROLE_USER"), func(c *gin.Context) {
rc := controllers.NewReservationController(db)
rc.Create(c)
})
apiCoreReservation.PUT(`/:id`, RoleMiddleware("ROLE_USER"), func(c *gin.Context) {
rc := controllers.NewReservationController(db)
rc.Update(c)
})
apiCoreReservation.DELETE(`/:id`, RoleMiddleware("ROLE_USER"), func(c *gin.Context) {
rc := controllers.NewReservationController(db)
rc.Delete(c)
})
}

// apiCoreReservation := apiCore.Group(`/api/reservation`)
// {
// apiCoreReservation.GET(`/list`, handleCoreAPI("/api/reservation/list"))
// apiCoreReservation.GET(`/status`, handleCoreAPI("/api/reservation/status"))
// apiCoreReservation.GET(`/:id`, handleCoreAPIWithId("/api/reservation"))
// apiCoreReservation.POST(`/new`, handleCoreAPI("/api/reservation/new"))
// apiCoreReservation.PUT(`/:id`, handleCoreAPIWithId("/api/reservation"))
// apiCoreReservation.DELETE(`/:id`, handleCoreAPIWithId("/api/reservation"))
// apiCoreReservation.Use(func(c *gin.Context) {
// if !authenticator(c) {
// c.AbortWithStatusJSON(http.StatusUnauthorized, gin.H{"msg": "Unauthorized"})
// return
// }
// c.Next()
// })

// apiCoreReservation.GET(`/list`, RoleMiddleware("ROLE_USER"), func(c *gin.Context) {
// rc := controllers.NewReservationController(db)
// rc.FindAll(c)
// })
// apiCoreReservation.GET(`/status`, RoleMiddleware("ROLE_USER"), func(c *gin.Context) {
// rc := controllers.NewReservationController(db)
// rc.ReservationStatus(c)
// })
// apiCoreReservation.GET(`/:id`, RoleMiddleware("ROLE_USER"), func(c *gin.Context) {
// rc := controllers.NewReservationController(db)
// rc.FindOne(c)
// })
// apiCoreReservation.POST(`/new`, RoleMiddleware("ROLE_USER"), func(c *gin.Context) {
// rc := controllers.NewReservationController(db)
// rc.Create(c)
// })
// apiCoreReservation.PUT(`/:id`, RoleMiddleware("ROLE_USER"), func(c *gin.Context) {
// rc := controllers.NewReservationController(db)
// rc.Update(c)
// })
// apiCoreReservation.DELETE(`/:id`, RoleMiddleware("ROLE_USER"), func(c *gin.Context) {
// rc := controllers.NewReservationController(db)
// rc.Delete(c)
// })
// }

apiCoreReservation := apiCore.Group(`/api/reservation`)
{
apiCoreReservation.GET(`/list`, handleCoreAPI("/api/reservation/list"))
apiCoreReservation.GET(`/status`, handleCoreAPI("/api/reservation/status"))
apiCoreReservation.GET(`/:id`, handleCoreAPIWithId("/api/reservation"))
apiCoreReservation.POST(`/new`, handleCoreAPI("/api/reservation/new"))
apiCoreReservation.PUT(`/:id`, handleCoreAPIWithId("/api/reservation"))
apiCoreReservation.DELETE(`/:id`, handleCoreAPIWithId("/api/reservation"))
}

apiCoreTag := apiCore.Group(`/api/tag`)
{
apiCoreTag.Use(func(c *gin.Context) {
Expand Down
Loading

0 comments on commit b91306b

Please sign in to comment.