diff --git a/src/server/server.go b/src/server/server.go index cdbf09a..fdc1430 100644 --- a/src/server/server.go +++ b/src/server/server.go @@ -13,6 +13,10 @@ import ( "gorm.io/gorm" ) +const ( + ENVIRONMENT_NAME_PRODUCTION = "production" +) + // CreateAdminApp creates the fiber app // // @title onepixel API @@ -34,19 +38,20 @@ import ( // @name X-API-Key func CreateAdminApp(db *gorm.DB) *fiber.App { app := fiber.New() - app.Use(logger.NewLogger()) + + switch config.Env { + case ENVIRONMENT_NAME_PRODUCTION: + docs.SwaggerInfo.Host = config.AdminHost + default: + app.Use(logger.NewLogger()) + docs.SwaggerInfo.Host = fmt.Sprintf("%s:%s", config.AdminHost, config.Port) + } apiV1 := app.Group("/api/v1") apiV1.Route("/users", api.UsersRoute(db)) apiV1.Route("/urls", api.UrlsRoute(db)) - if config.Env == "production" { - docs.SwaggerInfo.Host = config.AdminHost - } else { - docs.SwaggerInfo.Host = fmt.Sprintf("%s:%s", config.AdminHost, config.Port) - } - app.Get("/docs/*", swagger.HandlerDefault) return app