Skip to content

Commit

Permalink
Adds timeout defaults to the server
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinGallauner committed May 25, 2024
1 parent 12cc7b3 commit b43bc67
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions internal/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"net/http"
"os"
"strings"
"time"

"github.com/golang-jwt/jwt/v5"
_ "github.com/martingallauner/bookclub/docs"
Expand All @@ -16,8 +17,15 @@ import (

// StartServer starts the server :)
func StartServer(cfg *BookclubServer) error {
log.Print("Starting bookclub on port: 8080") //TODO:: make the port configurable
return http.ListenAndServe(":8080", cfg.Handler)
log.Print("Starting bookclub on port: 8080") //TODO:: make parameters configurable

s := &http.Server{
Addr: ":8080",
ReadHeaderTimeout: 500 * time.Millisecond,
ReadTimeout: 500 * time.Millisecond,
Handler: cfg.Handler,
}
return s.ListenAndServe()
}

type BookclubServer struct {
Expand Down

0 comments on commit b43bc67

Please sign in to comment.