mirror of
https://github.com/jwetzell/showbridge-go.git
synced 2026-09-10 15:39:25 +00:00
add read header timeout to http servers
This commit is contained in:
@@ -54,6 +54,7 @@ func (as *ApiServer) Start(config config.ApiConfig) {
|
|||||||
defer as.serverMu.Unlock()
|
defer as.serverMu.Unlock()
|
||||||
as.server = &http.Server{
|
as.server = &http.Server{
|
||||||
Addr: fmt.Sprintf(":%d", as.config.Port),
|
Addr: fmt.Sprintf(":%d", as.config.Port),
|
||||||
|
ReadHeaderTimeout: 5 * time.Second,
|
||||||
Handler: mux,
|
Handler: mux,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"log/slog"
|
"log/slog"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/google/jsonschema-go/jsonschema"
|
"github.com/google/jsonschema-go/jsonschema"
|
||||||
"github.com/jwetzell/showbridge-go/internal/common"
|
"github.com/jwetzell/showbridge-go/internal/common"
|
||||||
@@ -164,6 +165,7 @@ func (hs *HTTPServer) Start(ctx context.Context, router common.RouteIO) error {
|
|||||||
|
|
||||||
httpServer := &http.Server{
|
httpServer := &http.Server{
|
||||||
Addr: fmt.Sprintf(":%d", hs.Port),
|
Addr: fmt.Sprintf(":%d", hs.Port),
|
||||||
|
ReadHeaderTimeout: 5 * time.Second,
|
||||||
Handler: hs,
|
Handler: hs,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user