Skip to content

Commit

Permalink
Pass attributes of controller route in interceptor
Browse files Browse the repository at this point in the history
  • Loading branch information
decebals committed Jan 30, 2017
1 parent 5350e79 commit 84ea840
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
Expand Up @@ -344,6 +344,7 @@ protected void processRouteInterceptors(RouteContext routeContext) {
Route route = new Route(routeContext.getRequestMethod(), routeContext.getRequestUri(), interceptor);
route.setName(StringUtils.format("{}<{}>", Interceptor.class.getSimpleName(),
route.getRouteHandler().getClass().getSimpleName()));
route.bindAll(routeContext.getRoute().getAttributes());

// add route in chain
RouteMatch match = new RouteMatch(route, null);
Expand Down
17 changes: 17 additions & 0 deletions pippo-core/src/main/java/ro/pippo/core/route/Route.java
Expand Up @@ -197,6 +197,23 @@ public Route bind(String name, Object value) {
return this;
}

/**
* Copies all of the attributes from the specified map to this route.
*
* @param attributes
* @return
*/
public Route bindAll(Map<String, Object> attributes) {
this.attributes.putAll(attributes);

return this;
}

/**
* Returns an unmodifiable view of attributes.
*
* @return
*/
public Map<String, Object> getAttributes() {
return Collections.unmodifiableMap(attributes);
}
Expand Down

0 comments on commit 84ea840

Please sign in to comment.