From 3b8bf3017d823472f4dad2edf9e6e5c246a8081f Mon Sep 17 00:00:00 2001 From: Evgeniy Kulikov Date: Fri, 12 Feb 2021 18:48:52 +0300 Subject: [PATCH] Migrate to fasthttp v1.20.0 Signed-off-by: Evgeniy Kulikov --- app.go | 7 ++----- settings.go | 22 ---------------------- 2 files changed, 2 insertions(+), 27 deletions(-) diff --git a/app.go b/app.go index 34a1492..8e4a961 100644 --- a/app.go +++ b/app.go @@ -101,13 +101,10 @@ func newApp(ctx context.Context, opt ...Option) App { // FIXME don't work with StreamRequestBody, // some bugs with readMultipartForm + // https://github.com/valyala/fasthttp/issues/968 // a.web.DisablePreParseMultipartForm = true - // body streaming - // TODO should be replaced in future with - // - // a.web.StreamRequestBody = v.GetBool(cfgWebStreamRequestBody) - checkAndEnableStreaming(a.log, a.cfg, a.web) + a.web.StreamRequestBody = a.cfg.GetBool(cfgWebStreamRequestBody) // -- -- -- -- -- -- -- -- -- -- connections := make(map[string]float64) diff --git a/settings.go b/settings.go index b2dac09..206fd0a 100644 --- a/settings.go +++ b/settings.go @@ -4,7 +4,6 @@ import ( "fmt" "io" "os" - "reflect" "sort" "strconv" "strings" @@ -13,7 +12,6 @@ import ( "github.com/spf13/pflag" "github.com/spf13/viper" "github.com/valyala/fasthttp" - "go.uber.org/zap" ) type empty int @@ -90,26 +88,6 @@ var ignore = map[string]struct{}{ func (empty) Read([]byte) (int, error) { return 0, io.EOF } -// checkAndEnableStreaming is temporary shim, should be used before -// `StreamRequestBody` is not merged in fasthttp master -// TODO should be removed in future -func checkAndEnableStreaming(l *zap.Logger, v *viper.Viper, i interface{}) { - vi := reflect.ValueOf(i) - - if vi.Type().Kind() != reflect.Ptr { - return - } - - field := vi.Elem().FieldByName("StreamRequestBody") - if !field.IsValid() || field.Kind() != reflect.Bool { - l.Warn("stream request body not supported") - - return - } - - field.SetBool(v.GetBool(cfgWebStreamRequestBody)) -} - func settings() *viper.Viper { v := viper.New() v.AutomaticEnv()