Migrate to fasthttp v1.20.0

Signed-off-by: Evgeniy Kulikov <kim@nspcc.ru>
This commit is contained in:
Evgeniy Kulikov 2021-02-12 18:48:52 +03:00
parent a428a0b1b3
commit 3b8bf3017d
No known key found for this signature in database
GPG key ID: BF6AEE0A2A699BF2
2 changed files with 2 additions and 27 deletions

7
app.go
View file

@ -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)

View file

@ -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()