diff --git a/atreugo.go b/atreugo.go index c81bce9..02f5896 100644 --- a/atreugo.go +++ b/atreugo.go @@ -112,6 +112,7 @@ func newFasthttpServer(cfg Config) *fasthttp.Server { CloseOnShutdown: cfg.CloseOnShutdown, StreamRequestBody: cfg.StreamRequestBody, ConnState: cfg.ConnState, + ErrorHandler: cfg.ErrorHandler, Logger: cfg.Logger, TLSConfig: cfg.TLSConfig, FormValueFunc: cfg.FormValueFunc, diff --git a/types.go b/types.go index 5265ec7..d5550ba 100644 --- a/types.go +++ b/types.go @@ -118,6 +118,17 @@ type Config struct { // nolint:maligned // JSONMarshalFunc is used to marshal the response body to writer as JSON. JSONMarshalFunc JSONMarshalFunc + // ErrorHandler for returning a response in case of an error while receiving or parsing the request. + // + // The following is a non-exhaustive list of errors that can be expected as argument: + // * io.EOF + // * io.ErrUnexpectedEOF + // * ErrGetOnly + // * ErrSmallBuffer + // * ErrBodyTooLarge + // * ErrBrokenChunks + ErrorHandler func(ctx *fasthttp.RequestCtx, err error) + // Configurable view which is called when no matching route is // found. If it is not set, http.NotFound is used. NotFoundView View