about summary refs log tree commit diff stats
path: root/internal/server/server.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/server/server.go')
-rw-r--r--internal/server/server.go17
1 files changed, 10 insertions, 7 deletions
diff --git a/internal/server/server.go b/internal/server/server.go
index 4fda3dc..8838dbd 100644
--- a/internal/server/server.go
+++ b/internal/server/server.go
@@ -21,9 +21,9 @@ import (
 var config *cfg.Config
 
 var (
-	CommitSHA    string = "local"
-	ShortSHA     string = "local"
-	serverHeader string = fmt.Sprintf("website (%s)", ShortSHA)
+	CommitSHA    = "local"
+	ShortSHA     = "local"
+	serverHeader = fmt.Sprintf("website (%s)", ShortSHA)
 )
 
 type Config struct {
@@ -83,7 +83,7 @@ func New(runtimeConfig *Config) (*Server, error) {
 	top := http.NewServeMux()
 	mux, err := website.NewMux(config, runtimeConfig.Root)
 	if err != nil {
-		return nil, err
+		return nil, errors.Wrap(err, "could not create website mux")
 	}
 	log.Debug("binding main handler to", "host", runtimeConfig.BaseURL.Hostname()+"/")
 	hostname := runtimeConfig.BaseURL.Hostname()
@@ -95,14 +95,16 @@ func New(runtimeConfig *Config) (*Server, error) {
 		http.Redirect(w, r, newURL.String(), 301)
 	})
 
-	top.HandleFunc("/health", func(w http.ResponseWriter, r *http.Request) {
+	top.HandleFunc("/health", func(w http.ResponseWriter, _ *http.Request) {
 		w.WriteHeader(http.StatusOK)
 	})
 
 	listenAddress := net.JoinHostPort(runtimeConfig.ListenAddress, runtimeConfig.Port)
+
 	return &Server{
 		&http.Server{
-			Addr: listenAddress,
+			Addr:              listenAddress,
+			ReadHeaderTimeout: 1 * time.Minute,
 			Handler: sentryHandler.Handle(
 				serverHeaderHandler(
 					wrapHandlerWithLogging(top, wrappedHandlerOptions{
@@ -116,8 +118,9 @@ func New(runtimeConfig *Config) (*Server, error) {
 
 func (s *Server) Start() error {
 	if err := s.ListenAndServe(); err != http.ErrServerClosed {
-		return err
+		return errors.Wrap(err, "error creating/closing server")
 	}
+
 	return nil
 }