Skip to content

Commit

Permalink
feat: allow disabling swagger ui and disable it by default (#1026)
Browse files Browse the repository at this point in the history
* feat: allow disabling swagger ui and disable by default

* chore: Add codecov configuration to disable GitHub PR annotations
  • Loading branch information
fmartingr authored Dec 11, 2024
1 parent 4aa0f51 commit 87bc7a8
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
2 changes: 2 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
github_checks:
annotations: false
15 changes: 8 additions & 7 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,14 @@ func readDotEnv(logger *logrus.Logger) map[string]string {
}

type HttpConfig struct {
Enabled bool `env:"HTTP_ENABLED,default=True"`
Port int `env:"HTTP_PORT,default=8080"`
Address string `env:"HTTP_ADDRESS,default=:"`
RootPath string `env:"HTTP_ROOT_PATH,default=/"`
AccessLog bool `env:"HTTP_ACCESS_LOG,default=True"`
ServeWebUI bool `env:"HTTP_SERVE_WEB_UI,default=True"`
SecretKey []byte `env:"HTTP_SECRET_KEY"`
Enabled bool `env:"HTTP_ENABLED,default=True"`
Port int `env:"HTTP_PORT,default=8080"`
Address string `env:"HTTP_ADDRESS,default=:"`
RootPath string `env:"HTTP_ROOT_PATH,default=/"`
AccessLog bool `env:"HTTP_ACCESS_LOG,default=True"`
ServeWebUI bool `env:"HTTP_SERVE_WEB_UI,default=True"`
ServeSwagger bool `env:"HTTP_SERVE_SWAGGER,default=False"`
SecretKey []byte `env:"HTTP_SECRET_KEY"`
// Fiber Specific
BodyLimit int `env:"HTTP_BODY_LIMIT,default=1024"`
ReadTimeout time.Duration `env:"HTTP_READ_TIMEOUT,default=10s"`
Expand Down
5 changes: 4 additions & 1 deletion internal/http/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,10 @@ func (s *HttpServer) Setup(cfg *config.Config, deps *dependencies.Dependencies)
s.handle("/system", routes.NewSystemRoutes(s.logger))
s.handle("/bookmark", routes.NewBookmarkRoutes(s.logger, deps))
s.handle("/api/v1", api_v1.NewAPIRoutes(s.logger, deps, legacyRoutes.HandleLogin))
s.handle("/swagger", routes.NewSwaggerAPIRoutes(s.logger))

if cfg.Http.ServeSwagger {
s.handle("/swagger", routes.NewSwaggerAPIRoutes(s.logger))
}

s.http.Handler = s.engine
s.http.Addr = fmt.Sprintf("%s%d", cfg.Http.Address, cfg.Http.Port)
Expand Down

0 comments on commit 87bc7a8

Please sign in to comment.