Class SessionForRequest

java.lang.Object
io.micronaut.session.http.SessionForRequest

public class SessionForRequest extends Object
Utility class with methods to create or retrieve a session associated to a request.
Since:
1.1.0
Author:
Sergio del Amo
  • Constructor Details

    • SessionForRequest

      public SessionForRequest()
  • Method Details

    • create

      public static Session create(SessionStore sessionStore, io.micronaut.http.HttpRequest<?> request)
      Creates a session and stores it in the request attributes.
      Parameters:
      sessionStore - the session store
      request - the Http Request
      Returns:
      A new session stored in the request attributes
    • find

      public static Optional<Session> find(io.micronaut.http.HttpRequest<?> request)
      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 Request
      sessionStore - 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.