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

Function FromCookie

extractors/extractors.go:220–232  ·  view source on GitHub ↗

FromCookie creates an Extractor that retrieves a value from a specified cookie in the request. The function: - Retrieves the cookie value using the specified name - Returns ErrNotFound if the cookie is missing Parameters: - key: The name of the cookie from which to extract the value. Returns: A

(key string)

Source from the content-addressed store, hash-verified

218// // Cookie: "session_id=abc123" -> Output: "abc123"
219// // Missing cookie -> Output: ErrNotFound
220func FromCookie(key string) Extractor {
221 return Extractor{
222 Extract: func(c fiber.Ctx) (string, error) {
223 value := c.Cookies(key)
224 if value == "" {
225 return "", ErrNotFound
226 }
227 return value, nil
228 },
229 Key: key,
230 Source: SourceCookie,
231 }
232}
233
234// FromParam creates an Extractor that retrieves a value from a specified URL parameter in the request.
235// URL parameters are extracted from the route path (e.g., /users/:id).

Calls 1

CookiesMethod · 0.65