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

Function FromHeader

extractors/extractors.go:342–354  ·  view source on GitHub ↗

FromHeader creates an Extractor that retrieves a value from a specified HTTP header in the request. HTTP headers are commonly used for API keys, tokens, and other metadata. The function: - Retrieves the header value using the specified name - Returns ErrNotFound if the header is missing Parameters

(header string)

Source from the content-addressed store, hash-verified

340// // Header: "X-API-Key: abc123" -> Output: "abc123"
341// // Missing header -> Output: ErrNotFound
342func FromHeader(header string) Extractor {
343 return Extractor{
344 Extract: func(c fiber.Ctx) (string, error) {
345 value := c.Get(header)
346 if value == "" {
347 return "", ErrNotFound
348 }
349 return value, nil
350 },
351 Key: header,
352 Source: SourceHeader,
353 }
354}
355
356// FromQuery creates an Extractor that retrieves a value from a specified query parameter in the request.
357// Query parameters are extracted from the URL query string (e.g., ?key=value&foo=bar).

Calls 1

GetMethod · 0.65