Skip to content

Commit

Permalink
enhance: service: add http timeouts
Browse files Browse the repository at this point in the history
  • Loading branch information
grokify committed Apr 17, 2023
1 parent 607f0e2 commit 7df27ca
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion pkg/service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"net/http"
"strconv"
"strings"
"time"

"github.com/apex/gateway"
"github.com/aws/aws-lambda-go/events"
Expand Down Expand Up @@ -303,7 +304,20 @@ func ServeNetHTTP(svc Service) {
log.Info().
Int("port", svc.Config.Port).
Msg("STARTING_NET_HTTP")
clog.Fatal(http.ListenAndServe(portAddress(svc.Config.Port), getHTTPServeMux(svc)))

srv := &http.Server{
Addr: portAddress(svc.Config.Port),
ReadTimeout: 3 * time.Minute,
WriteTimeout: 3 * time.Minute,
IdleTimeout: 30 * time.Second,
ReadHeaderTimeout: 2 * time.Second,
Handler: getHTTPServeMux(svc),
// TLSConfig: tlsConfig,
}

clog.Fatal(srv.ListenAndServe())

// clog.Fatal(http.ListenAndServe(portAddress(svc.Config.Port), getHTTPServeMux(svc)))
}

func ServeFastHTTP(svc Service) {
Expand Down

0 comments on commit 7df27ca

Please sign in to comment.