Skip to content
This repository has been archived by the owner on Nov 4, 2020. It is now read-only.

Commit

Permalink
Fix routes issues related to gin-gonic/gin#1681
Browse files Browse the repository at this point in the history
  • Loading branch information
L1ghtman2k committed Jul 27, 2020
1 parent f5e7b16 commit 1bc96e2
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions cmd/web/server/gin/gin.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ func (ds *dserver) MapRoutesAndStart() error {
ds.logger.Error(err)
return err
}

ds.router.Use(static.Serve("/", static.LocalFile("./views", true)))
ds.router.NoRoute(authMiddleware.MiddlewareFunc(), func(c *gin.Context) {
claims := jwt.ExtractClaims(c)
Expand Down Expand Up @@ -99,14 +100,20 @@ func (ds *dserver) MapRoutesAndStart() error {
serviceRoute.PATCH("/:id", sctrl.Update)
serviceRoute.DELETE("/:id", sctrl.Delete)
}

roundRote := api.Group("/round")

{

roundRoute := api.Group("/round")
rcli := client.NewRoundClient(c)
rctrl := handler.NewRoundController(ds.logger, rcli)
roundRote.GET("/", rctrl.GetAll)
roundRote.GET("/:id", rctrl.GetByID)
roundRote.GET("/last_non_elapsing", rctrl.GetLastNonElapsingRound)
roundRoute.GET("/", rctrl.GetAll)
roundRoute.GET("/:id", rctrl.GetByID)

//https://github.com/gin-gonic/gin/issues/1681
lastRoundRoute := api.Group("/last_non_elapsing")
lastRoundRoute.GET("/", rctrl.GetLastNonElapsingRound)

}

serviceGroupRoute := api.Group("/service_group")
Expand Down Expand Up @@ -142,12 +149,16 @@ func (ds *dserver) MapRoutesAndStart() error {
hostRoute.DELETE("/:id", hctrl.Delete)
}

checkRoute := api.Group("/check")

{
hcli := client.NewCheckClient(c)
hctrl := handler.NewCheckController(ds.logger, hcli)
checkRoute.GET("/:RoundID/:ServiceID", hctrl.GetByRoundServiceID)
checkRoute.GET("/:id", hctrl.GetAllByRoundID)

//https://github.com/gin-gonic/gin/issues/1681
checkSpecificRoute := api.Group("/check")
checkSpecificRoute.GET("/:RoundID/:ServiceID", hctrl.GetByRoundServiceID)
checkAllRoute := api.Group("/check_all")
checkAllRoute.GET("/:id", hctrl.GetAllByRoundID)
}

configRoute := api.Group("/config")
Expand Down

0 comments on commit 1bc96e2

Please sign in to comment.