/** * Creates a new HTTP context. * * @param request the HTTP request * @param components the context components. */ public Context(Request request, JavaContextComponents components) { this.request = request; this.id = this.request.asScala().id(); this.response = new Response(); this.session = new Session(this.request.session()); this.flash = new Flash(this.request.flash()); this.args = new HashMap<>(); this.components = components; }
/** * Creates a new HTTP context. * * @param request the HTTP request * @param components the context components. */ public Context(Request request, JavaContextComponents components) { this.request = request; this.id = this.request.asScala().id(); this.response = new Response(); this.session = new Session(this.request.session()); this.flash = new Flash(this.request.flash()); this.args = new HashMap<>(); this.components = components; }
/** * Creates a new HTTP context. * * @param request the HTTP request * @param components the context components. */ public Context(Request request, JavaContextComponents components) { this.request = request; this.id = this.request.asScala().id(); this.response = new Response(); this.session = new Session(this.request.session()); this.flash = new Flash(this.request.flash()); this.args = new HashMap<>(); this.components = components; }
/** * Retrieves the username from the HTTP request; the default is to read from the session cookie. * * @param req the current request * @return the username if the user is authenticated. */ public Optional<String> getUsername(Request req) { return req.session().getOptional("username"); }
/** * Retrieves the username from the HTTP request; the default is to read from the session cookie. * * @param req the current request * @return the username if the user is authenticated. */ public Optional<String> getUsername(Request req) { return req.session().getOptional("username"); }
/** * @param request Current request * @return The session carried by this result. Reads the given request's session if this result does not has a session. */ public Session session(Http.Request request) { if(session != null) { return session; } else { return request.session(); } }
/** * @param request Current request * @return The session carried by this result. Reads the given request's session if this result does not has a session. */ public Session session(Http.Request request) { if(session != null) { return session; } else { return request.session(); } }
/** * @param request Current request * @return The session carried by this result. Reads the given request's session if this result does not has a session. */ public Session session(Http.Request request) { if(session != null) { return session; } else { return request.session(); } }
/** * Retrieves the username from the HTTP request; the default is to read from the session cookie. * * @param req the current request * @return the username if the user is authenticated. */ public Optional<String> getUsername(Request req) { return req.session().getOptional("username"); }