build with ko instead of nix
1 file changed, 9 insertions(+), 7 deletions(-)
changed files
M internal/server/server.go → internal/server/server.go
@@ -8,6 +8,7 @@ "net/http" "net/url" "os" "slices" + "strconv" "time" "website/internal/builder"@@ -34,14 +35,15 @@ Development bool `conf:"default:false,flag:dev"` 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 @@ if err != nil { 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 @@ IdleTimeout: 15 * time.Minute, }, ), 0), }, - config: config, - tls: runtimeConfig.TLS, + config: config, + runtimeConfig: runtimeConfig, }, nil }@@ -207,7 +209,7 @@ return s.serveTCP() } 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") }