Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Timeouts changes #532

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions api.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@ func stopBrowsersMiddleware(next http.Handler) http.Handler {
})
}

func timeoutMiddleware(next http.Handler) http.Handler {
return http.TimeoutHandler(next, 25*time.Second, "")
}

type ApiServer struct {
Collection *ProxyCollection
Metrics *metricsContainer
Expand All @@ -40,8 +36,13 @@ type ApiServer struct {
const (
wait_timeout = 30 * time.Second
read_timeout = 15 * time.Second
idle_timeout = 60 * time.Second
)

func timeoutMiddleware(next http.Handler) http.Handler {
return http.TimeoutHandler(next, idle_timeout, "Timeout from middleware\n")
}

func NewServer(m *metricsContainer, logger zerolog.Logger) *ApiServer {
return &ApiServer{
Collection: NewProxyCollection(),
Expand All @@ -61,7 +62,7 @@ func (server *ApiServer) Listen(addr string) error {
Handler: server.Routes(),
WriteTimeout: wait_timeout,
ReadTimeout: read_timeout,
IdleTimeout: 60 * time.Second,
IdleTimeout: idle_timeout,
}

err := server.http.ListenAndServe()
Expand Down