diff options
Diffstat (limited to 'internal/server/server.go')
-rw-r--r-- | internal/server/server.go | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/internal/server/server.go b/internal/server/server.go index e75efd3..556c660 100644 --- a/internal/server/server.go +++ b/internal/server/server.go @@ -8,6 +8,7 @@ import ( "net/url" "os" "slices" + "strconv" "time" "website/internal/builder" @@ -34,14 +35,15 @@ type Config struct { Root string `conf:"default:website"` Redirect bool `conf:"default:false"` ListenAddress string `conf:"default:localhost"` - Port string `conf:"default:3000,short:p"` + Port int `conf:"default:3000,short:p"` + TLSPort int `conf:"default:443"` TLS bool `conf:"default:false"` } type Server struct { *http.Server - config *cfg.Config - tls bool + runtimeConfig *Config + config *cfg.Config } func applyDevModeOverrides(config *cfg.Config, listenAddress string) { @@ -108,7 +110,7 @@ func New(runtimeConfig *Config) (*Server, error) { return nil, errors.WithMessage(err, "error parsing configuration file") } - listenAddress := net.JoinHostPort(runtimeConfig.ListenAddress, runtimeConfig.Port) + listenAddress := net.JoinHostPort(runtimeConfig.ListenAddress, strconv.Itoa(runtimeConfig.Port)) top := http.NewServeMux() if runtimeConfig.Development { @@ -193,8 +195,8 @@ func New(runtimeConfig *Config) (*Server, error) { }, ), 0), }, - config: config, - tls: runtimeConfig.TLS, + config: config, + runtimeConfig: runtimeConfig, }, nil } @@ -207,7 +209,7 @@ func (s *Server) serve(tls bool) error { } func (s *Server) Start() error { - if err := s.serve(s.tls); err != http.ErrServerClosed { + if err := s.serve(s.runtimeConfig.TLS); err != http.ErrServerClosed { return errors.Wrap(err, "error creating/closing server") } |