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

Function newSessionCtx

middleware/csrf/csrf_test.go:2893–2899  ·  view source on GitHub ↗

newSessionCtx builds a fiber.Ctx carrying the given session_id cookie. The session middleware is intentionally not run, so the session manager falls back to loading the session from the store (the else branch).

(app *fiber.App, sessionID string)

Source from the content-addressed store, hash-verified

2891// session middleware is intentionally not run, so the session manager falls back
2892// to loading the session from the store (the else branch).
2893func newSessionCtx(app *fiber.App, sessionID string) fiber.Ctx {
2894 reqCtx := &fasthttp.RequestCtx{}
2895 if sessionID != "" {
2896 reqCtx.Request.Header.SetCookie("session_id", sessionID)
2897 }
2898 return app.AcquireCtx(reqCtx)
2899}
2900
2901// Test_SessionManager_GetRaw_StoreError covers the error branch when loading the
2902// session from the store fails.

Calls 2

AcquireCtxMethod · 0.80
SetCookieMethod · 0.45

Tested by

no test coverage detected