From 0ca69fa67282f8225df690fccf3a4fae37834639 Mon Sep 17 00:00:00 2001 From: Sergio VS Date: Thu, 19 Jan 2023 12:53:36 +0100 Subject: [PATCH] fix(config/fasthttp): add FormValueFunc --- atreugo.go | 1 + atreugo_test.go | 2 +- types.go | 6 ++++++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/atreugo.go b/atreugo.go index ee51b35..32713d9 100644 --- a/atreugo.go +++ b/atreugo.go @@ -109,6 +109,7 @@ func newFasthttpServer(cfg Config) *fasthttp.Server { ConnState: cfg.ConnState, Logger: cfg.Logger, TLSConfig: cfg.TLSConfig, + FormValueFunc: cfg.FormValueFunc, } } diff --git a/atreugo_test.go b/atreugo_test.go index 5810e16..d4434f5 100644 --- a/atreugo_test.go +++ b/atreugo_test.go @@ -24,7 +24,6 @@ import ( var notConfigFasthttpFields = []string{ "Handler", "ErrorHandler", - "MaxKeepaliveDuration", // Deprecated: Use IdleTimeout instead. } func Test_New(t *testing.T) { //nolint:funlen,gocognit,gocyclo @@ -231,6 +230,7 @@ func Test_newFasthttpServer(t *testing.T) { //nolint:funlen ConnState: func(net.Conn, fasthttp.ConnState) {}, Logger: testLog, TLSConfig: &tls.Config{ServerName: "test", MinVersion: tls.VersionTLS13}, + FormValueFunc: func(ctx *fasthttp.RequestCtx, key string) []byte { return nil }, } srv := newFasthttpServer(cfg) diff --git a/types.go b/types.go index 005d18a..8f33f33 100644 --- a/types.go +++ b/types.go @@ -354,6 +354,12 @@ type Config struct { // nolint:maligned // called when a client connection changes state. See the // ConnState type and associated constants for details. ConnState func(net.Conn, fasthttp.ConnState) + + // FormValueFunc, which is used by RequestCtx.FormValue and support for customising + // the behaviour of the RequestCtx.FormValue function. + // + // NetHttpFormValueFunc gives a FormValueFunc func implementation that is consistent with net/http. + FormValueFunc fasthttp.FormValueFunc } // StaticFS represents settings for serving static files