From e7545b2fb6975d4dd4eda4f7e44a8a2b38b7c087 Mon Sep 17 00:00:00 2001 From: Muhammed Efe Cetin Date: Fri, 30 Aug 2024 19:54:09 +0300 Subject: [PATCH] update --- binder.go | 6 ------ ctx_interface_gen.go | 12 ++++++------ middleware/logger/tags.go | 4 ++-- 3 files changed, 8 insertions(+), 14 deletions(-) diff --git a/binder.go b/binder.go index ef8ccce776..86bf2bd4cd 100644 --- a/binder.go +++ b/binder.go @@ -21,12 +21,6 @@ type Bind struct { strict bool } -func (c *DefaultCtx) Bind() *Bind { - b := binderPool.Get().(*Bind) - b.ctx = c - return b -} - func (b *Bind) Strict() *Bind { b.strict = true return b diff --git a/ctx_interface_gen.go b/ctx_interface_gen.go index 7709f7c929..f5f35cd880 100644 --- a/ctx_interface_gen.go +++ b/ctx_interface_gen.go @@ -11,8 +11,7 @@ import ( "github.com/valyala/fasthttp" ) -// Ctx represents the Context which hold the HTTP request and response. -// It has methods for the request query string, parameters, body, HTTP headers and so on. +// Ctx represents the Context which hold the HTTP request and response.\nIt has methods for the request query string, parameters, body, HTTP headers and so on. type Ctx interface { // Accepts checks if the specified extensions or content types are acceptable. Accepts(offers ...string) string @@ -31,6 +30,8 @@ type Ctx interface { Attachment(filename ...string) // BaseURL returns (protocol + host + base path). BaseURL() string + Bind() *Bind + Validate(v any) error // BodyRaw contains the raw body submitted in a POST request. // Returned value is only valid within the handler. Do not store any references. // Make copies or use the Immutable setting instead. @@ -322,10 +323,9 @@ type Ctx interface { isLocalHost(address string) bool // IsFromLocal will return true if request came from local. IsFromLocal() bool - // Bind You can bind body, cookie, headers etc. into the map, map slice, struct easily by using Binding method. - // It gives custom binding support, detailed binding options and more. - // Replacement of: BodyParser, ParamsParser, GetReqHeaders, GetRespHeaders, AllParams, QueryParser, ReqHeaderParser - Bind() *Bind + // AllParams Params is used to get all route parameters. + // Using Params method to get params. + GetParams() map[string]string // Reset is a method to reset context fields by given request when to use server handlers. Reset(fctx *fasthttp.RequestCtx) // Release is a method to reset context fields when to use ReleaseCtx() diff --git a/middleware/logger/tags.go b/middleware/logger/tags.go index 7fc014c789..3679745446 100644 --- a/middleware/logger/tags.go +++ b/middleware/logger/tags.go @@ -99,9 +99,9 @@ func createTagMap(cfg *Config) map[string]LogFunc { return output.Write(c.Response().Body()) }, TagReqHeaders: func(output Buffer, c fiber.Ctx, _ *Data, _ string) (int, error) { - out := c.GetRespHeaders() - fmt.Print(out) + out := c.GetReqHeaders() reqHeaders := make([]string, 0) + for k, v := range out { reqHeaders = append(reqHeaders, k+"="+strings.Join(v, ",")) }