forked from TrueCloudLab/frostfs-http-gw
Migrate to fasthttp v1.20.0
Signed-off-by: Evgeniy Kulikov <kim@nspcc.ru>
This commit is contained in:
parent
a428a0b1b3
commit
3b8bf3017d
2 changed files with 2 additions and 27 deletions
7
app.go
7
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)
|
||||
|
|
22
settings.go
22
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()
|
||||
|
|
Loading…
Reference in a new issue