ekko: configurable read write and readheader timeouts
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
package ekko
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/labstack/echo/v4"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
slogecho "github.com/samber/slog-echo"
|
||||
@@ -13,6 +15,9 @@ type Ekko struct {
|
||||
routeFn func(e *echo.Echo) error
|
||||
logFilters []slogecho.Filter
|
||||
otelmiddleware echo.MiddlewareFunc
|
||||
|
||||
writeTimeout time.Duration
|
||||
readHeaderTimeout time.Duration
|
||||
}
|
||||
|
||||
type RouteFn func(e *echo.Echo) error
|
||||
@@ -46,3 +51,15 @@ func WithOtelMiddleware(mw echo.MiddlewareFunc) func(*Ekko) {
|
||||
ek.otelmiddleware = mw
|
||||
}
|
||||
}
|
||||
|
||||
func WithWriteTimeout(t time.Duration) func(*Ekko) {
|
||||
return func(ek *Ekko) {
|
||||
ek.writeTimeout = t
|
||||
}
|
||||
}
|
||||
|
||||
func WithReadHeaderTimeout(t time.Duration) func(*Ekko) {
|
||||
return func(ek *Ekko) {
|
||||
ek.readHeaderTimeout = t
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user