Skip to content

Commit ec34ca7

Browse files
on development env swagger points to localhost
1 parent 5916b16 commit ec34ca7

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

cmd/server/main.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"syscall"
1010
"time"
1111

12+
swaggerdocs "github.com/capyrpi/api/docs/swagger"
1213
"github.com/capyrpi/api/internal/config"
1314
"github.com/capyrpi/api/internal/database"
1415
"github.com/capyrpi/api/internal/handler"
@@ -50,6 +51,8 @@ func main() {
5051

5152
slog.Info("starting server", "env", cfg.Env)
5253

54+
configureSwagger(cfg)
55+
5356
ctx := context.Background()
5457

5558
if err := database.RunMigrations(ctx, cfg.Database.URL, cfg.Database.MigrationsPath); err != nil {
@@ -111,3 +114,12 @@ func main() {
111114

112115
slog.Info("server stopped")
113116
}
117+
118+
func configureSwagger(cfg *config.Config) {
119+
if cfg.Env != "development" {
120+
return
121+
}
122+
123+
swaggerdocs.SwaggerInfo.Host = "localhost:" + cfg.Server.Port
124+
swaggerdocs.SwaggerInfo.Schemes = []string{"http"}
125+
}

0 commit comments

Comments
 (0)