Package io.micronaut.session.http
Class SessionForRequest
java.lang.Object
io.micronaut.session.http.SessionForRequest
Utility class with methods to create or retrieve a session associated to a request.
- Since:
- 1.1.0
- Author:
- Sergio del Amo
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic Session
create
(SessionStore sessionStore, io.micronaut.http.HttpRequest<?> request) Creates a session and stores it in the request attributes.find
(io.micronaut.http.HttpRequest<?> request) Finds a session.static Session
findOrCreate
(io.micronaut.http.HttpRequest<?> request, SessionStore sessionStore) Finds a session or creates a new one and stores it in the request attributes.
-
Constructor Details
-
SessionForRequest
public SessionForRequest()
-
-
Method Details
-
create
Creates a session and stores it in the request attributes.- Parameters:
sessionStore
- the session storerequest
- the Http Request- Returns:
- A new session stored in the request attributes
-
find
Finds a session.- Parameters:
request
- the Http Request- Returns:
- A session if found in the request attributes.
-
findOrCreate
public static Session findOrCreate(io.micronaut.http.HttpRequest<?> request, SessionStore sessionStore) Finds a session or creates a new one and stores it in the request attributes.- Parameters:
request
- The Http RequestsessionStore
- The session store to create the session if not found- Returns:
- A session if found in the request attributes or a new session stored in the request attributes.
-