java.lang.Object
io.jooby.handler.WebVariables
- All Implemented Interfaces:
Route.Aware
,Route.Filter
Add common variables to as
Context
attributes so they are accessible from template
engine.
Usage:
use(new WebVariables());
get("/", ctx -> new ModelAndView("index.ftl"));
Template engine will be able to access to the following attributes:
- contextPath. Empty when context path is set to /
or actual context path. -
path. Current request path, as defined by Context.getRequestPath()
. - user. Current user
(if any) as defined by Context.getUser()
.
- Since:
- 2.4.0
- Author:
- edgar
-
Constructor Summary
ConstructorDescriptionCreates a new web variables.WebVariables
(String scope) Creates a web variables under the given scope. -
Method Summary
Modifier and TypeMethodDescriptionapply
(Route.Handler next) Chain the filter within next handler.Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.jooby.Route.Aware
setRoute
Methods inherited from interface io.jooby.Route.Filter
then, then
-
Constructor Details
-
WebVariables
Creates a web variables under the given scope.- Parameters:
scope
- Scope to use.
-
WebVariables
public WebVariables()Creates a new web variables.
-
-
Method Details
-
apply
Description copied from interface:Route.Filter
Chain the filter within next handler.- Specified by:
apply
in interfaceRoute.Filter
- Parameters:
next
- Next handler.- Returns:
- A new handler.
-