bind
Muhammed Efe Cetin 2023-08-06 22:56:49 +03:00
parent 967e52a5e0
commit 8e6b3bb2e4
No known key found for this signature in database
GPG Key ID: 0AA4D45CBAA86F73
3 changed files with 2 additions and 18 deletions

8
app.go
View File

@ -385,12 +385,6 @@ type Config struct {
// Optional. Default: DefaultColors
ColorScheme Colors `json:"color_scheme"`
// If you want to validate header/form/query... automatically when to bind, you can define struct validator.
// Fiber doesn't have default validator, so it'll skip validator step if you don't use any validator.
//
// Default: nil
StructValidator StructValidator
// RequestMethods provides customizibility for HTTP methods. You can add/remove methods as you wish.
//
// Optional. Default: DefaultMethods
@ -725,8 +719,6 @@ func (app *App) Use(args ...any) Router {
app.register([]string{methodUse}, prefix, nil, nil, handlers...)
}
app.register([]string{methodUse}, prefix, nil, handlers...)
return app
}

View File

@ -116,11 +116,7 @@ func New(config ...Config) fiber.Handler {
Body: utils.CopyBytes(c.Response().Body()),
}
{
headers := make(map[string]string)
if err := c.Bind().RespHeader(headers); err != nil {
return fmt.Errorf("failed to bind to response headers: %w", err)
}
headers := c.GetRespHeaders()
if cfg.KeepResponseHeaders == nil {
// Keep all
res.Headers = headers

View File

@ -102,11 +102,7 @@ func createTagMap(cfg *Config) map[string]LogFunc {
return output.Write(c.Response().Body())
},
TagReqHeaders: func(output Buffer, c fiber.Ctx, data *Data, extraParam string) (int, error) {
out := make(map[string]string, 0)
if err := c.Bind().Header(&out); err != nil {
return 0, err
}
out := c.GetReqHeaders()
reqHeaders := make([]string, 0)
for k, v := range out {
reqHeaders = append(reqHeaders, k+"="+v)