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

Method Get

middleware/session/store.go:99–108  ·  view source on GitHub ↗

Get will get/create a session. This function will return an ErrSessionAlreadyLoadedByMiddleware if the session is already loaded by the middleware. Parameters: - c: The Fiber context. Returns: - *Session: The session object. - error: An error if the session retrieval fails or if the session is al

(c fiber.Ctx)

Source from the content-addressed store, hash-verified

97// // handle error
98// }
99func (s *Store) Get(c fiber.Ctx) (*Session, error) {
100 // If session is already loaded in the context,
101 // it should not be loaded again
102 _, ok := c.Locals(middlewareContextKey).(*Middleware)
103 if ok {
104 return nil, ErrSessionAlreadyLoadedByMiddleware
105 }
106
107 return s.getSession(c)
108}
109
110// getSession retrieves a session based on the context.
111//

Callers 15

Test_CSRF_WithSessionFunction · 0.95
Test_Store_GetFunction · 0.95
Test_Store_DeleteSessionFunction · 0.95
Test_Store_GetByIDFunction · 0.95
Test_SessionFunction · 0.95
Test_Session_TypesFunction · 0.95
Test_Session_Store_ResetFunction · 0.95
Test_Session_KeyTypesFunction · 0.95
Test_Session_SaveFunction · 0.95

Calls 2

getSessionMethod · 0.95
LocalsMethod · 0.65

Tested by 15

Test_CSRF_WithSessionFunction · 0.76
Test_Store_GetFunction · 0.76
Test_Store_DeleteSessionFunction · 0.76
Test_Store_GetByIDFunction · 0.76
Test_SessionFunction · 0.76
Test_Session_TypesFunction · 0.76
Test_Session_Store_ResetFunction · 0.76
Test_Session_KeyTypesFunction · 0.76
Test_Session_SaveFunction · 0.76