From eb7f65c3712e0e9c02b2d31e2200af442a8799c9 Mon Sep 17 00:00:00 2001 From: gari8 Date: Wed, 17 May 2023 16:35:54 +0900 Subject: [PATCH] ref #36 fix endpoint prefix --- main.go | 9 +++++---- worker/handler.go | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/main.go b/main.go index d79b042..eb39402 100644 --- a/main.go +++ b/main.go @@ -48,9 +48,10 @@ func main() { app.GET("/", func(ctx *gin.Context) { ctx.String(http.StatusOK, "It works") }) - app.GET("/users/me", handleResponse(userController.GetMe)) - app.PUT("/reports/:reportId", handleResponse(reportController.ReviewReport, http.StatusNoContent)) - orgs := app.Group("/organizations") + api := app.Group("/api/v1") + api.GET("/users/me", handleResponse(userController.GetMe)) + api.PUT("/reports/:reportId", handleResponse(reportController.ReviewReport, http.StatusNoContent)) + orgs := api.Group("/organizations") orgs.Use(middleware.Authentication(userPersistence, cfg)) { orgs.GET("/", handleResponse(organizationController.GetOrganizations)) @@ -75,7 +76,7 @@ func runApp(app *gin.Engine, port int) { docs.SwaggerInfo.Description = "Reportify" docs.SwaggerInfo.Version = "1.0" docs.SwaggerInfo.Host = fmt.Sprintf("localhost:%d", port) - docs.SwaggerInfo.BasePath = "/" + docs.SwaggerInfo.BasePath = "/api/v1" docs.SwaggerInfo.Schemes = []string{"http"} app.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler)) log.Println(fmt.Sprintf("http://localhost:%d", port)) diff --git a/worker/handler.go b/worker/handler.go index 2858143..c7530cf 100644 --- a/worker/handler.go +++ b/worker/handler.go @@ -32,7 +32,7 @@ func (h handler) CommentReport(payload string) error { return err } - if _, err = h.Http.Put(fmt.Sprintf("http://backend:8080/reports/%s", m.ID), d); err != nil { + if _, err = h.Http.Put(fmt.Sprintf("http://backend:8080/api/v1/reports/%s", m.ID), d); err != nil { return err } return nil