Skip to content

Commit

Permalink
server: api: rest: Change API URL and add redirect URLs
Browse files Browse the repository at this point in the history
  • Loading branch information
ish-hcc committed Jul 4, 2024
1 parent 195b29e commit 913bfbf
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
12 changes: 11 additions & 1 deletion server/pkg/api/rest/route/swagger.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,19 @@ import (
"github.com/cloud-barista/cm-honeybee/server/common"
"github.com/labstack/echo/v4"
echoSwagger "github.com/swaggo/echo-swagger"
"net/http"
"strings"
)

func RegisterSwagger(e *echo.Echo) {
e.GET("/"+strings.ToLower(common.ShortModuleName)+"/swagger/*", echoSwagger.WrapHandler)
swaggerRedirect := func(c echo.Context) error {
return c.Redirect(http.StatusMovedPermanently, "/"+strings.ToLower(common.ShortModuleName)+"/api/index.html")
}
e.GET("", swaggerRedirect)
e.GET("/", swaggerRedirect)
e.GET("/"+strings.ToLower(common.ShortModuleName), swaggerRedirect)
e.GET("/"+strings.ToLower(common.ShortModuleName)+"/", swaggerRedirect)
e.GET("/"+strings.ToLower(common.ShortModuleName)+"/api", swaggerRedirect)
e.GET("/"+strings.ToLower(common.ShortModuleName)+"/api/", swaggerRedirect)
e.GET("/"+strings.ToLower(common.ShortModuleName)+"/api/*", echoSwagger.WrapHandler)
}
2 changes: 1 addition & 1 deletion server/pkg/api/rest/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func Init() {

// Display API Docs Dashboard when server starts
endpoint := getLocalIP() + ":" + config.CMHoneybeeConfig.CMHoneybee.Listen.Port
apiDocsDashboard := " http://" + endpoint + "/" + strings.ToLower(common.ShortModuleName) + "/swagger/index.html"
apiDocsDashboard := " http://" + endpoint + "/" + strings.ToLower(common.ShortModuleName) + "/api/index.html"

fmt.Println("\n ")
fmt.Println(" CM-Honeybee repository:")
Expand Down

0 comments on commit 913bfbf

Please sign in to comment.