Module io.jooby

Class WebVariables

java.lang.Object
io.jooby.handler.WebVariables
All Implemented Interfaces:
Route.Aware, Route.Filter

public class WebVariables extends Object implements 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 Details

    • WebVariables

      public WebVariables(@NonNull String scope)
      Creates a web variables under the given scope.
      Parameters:
      scope - Scope to use.
    • WebVariables

      public WebVariables()
      Creates a new web variables.
  • Method Details