public class WebVariables extends Object implements Route.Decorator
Context
attributes so they are accessible from template
engine.
Usage:
decorator(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()
.Constructor and Description |
---|
WebVariables()
Creates a new web variables.
|
WebVariables(String scope)
Creates a web variables under the given scope.
|
Modifier and Type | Method and Description |
---|---|
Route.Handler |
apply(Route.Handler next)
Chain the decorator within next handler.
|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
then, then
setRoute
public WebVariables(@Nonnull String scope)
scope
- Scope to use.public WebVariables()
@Nonnull public Route.Handler apply(@Nonnull Route.Handler next)
Route.Decorator
apply
in interface Route.Decorator
next
- Next handler.Copyright © 2023. All rights reserved.