Skip to content

Commit

Permalink
Add HTTP tls (issue kuskoman#393)
Browse files Browse the repository at this point in the history
  • Loading branch information
satk0 committed Dec 19, 2024
1 parent a32b098 commit 2c40985
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
9 changes: 8 additions & 1 deletion internal/startup_manager/startup_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ var (
// AppServer defines the behavior of an application server
type AppServer interface {
ListenAndServe() error
ListenAndServeTLS(certFile, keyFile string) error
Shutdown(ctx context.Context) error
}

Expand Down Expand Up @@ -176,7 +177,13 @@ func (sm *StartupManager) startServer(cfg *config.Config) {

go func() {
slog.Info("starting server", "host", cfg.Server.Host, "port", cfg.Server.Port)
err := appServer.ListenAndServe()
var err error
if cfg.Server.EnableSSL {
err = appServer.ListenAndServeTLS(cfg.Server.CertFile, cfg.Server.KeyFile)
} else {
err = appServer.ListenAndServe()
}

sm.serverErrorChan <- err
}()
}
Expand Down
7 changes: 5 additions & 2 deletions pkg/config/exporter_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,11 @@ type ServerConfig struct {
// with the default windows firewall configuration.
// Alternatively you can change the firewall configuration to allow
// connections to the port from all interfaces.
Host string `yaml:"host"`
Port int `yaml:"port"`
Host string `yaml:"host"`
Port int `yaml:"port"`
CertFile string `yaml:"certFile"`
KeyFile string `yaml:"keyFile"`
EnableSSL bool `yaml:"enableSSL"`
}

// LoggingConfig represents the logging configuration
Expand Down

0 comments on commit 2c40985

Please sign in to comment.