MCPcopy
hub / github.com/gofiber/fiber / GetReqHeader

Function GetReqHeader

req.go:480–486  ·  view source on GitHub ↗

GetReqHeader returns the HTTP request header specified by filed. This function is generic and can handle different headers type values. If the generic type cannot be matched to a supported type, the function returns the default value (if provided) or the zero value of type V.

(c Ctx, key string, defaultValue ...V)

Source from the content-addressed store, hash-verified

478// If the generic type cannot be matched to a supported type, the function
479// returns the default value (if provided) or the zero value of type V.
480func GetReqHeader[V GenericType](c Ctx, key string, defaultValue ...V) V {
481 v, err := genericParseType[V](c.App().toString(c.Request().Header.Peek(key)))
482 if err != nil && len(defaultValue) > 0 {
483 return defaultValue[0]
484 }
485 return v
486}
487
488// GetHeaders (a.k.a GetReqHeaders) returns the HTTP request headers.
489// Returned value is only valid within the handler. Do not store any references.

Callers 1

GetMethod · 0.85

Calls 3

toStringMethod · 0.80
AppMethod · 0.65
RequestMethod · 0.65

Tested by

no test coverage detected