Skip to content

Commit

Permalink
Add getRoute() method in RouteContext (#347)
Browse files Browse the repository at this point in the history
  • Loading branch information
decebals committed Jan 29, 2017
1 parent daba150 commit 5350e79
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ public class DefaultRouteContext implements RouteContext {
protected final Response response;
protected final Iterator<RouteMatch> iterator;

private Route route;

public DefaultRouteContext(Application application, Request request, Response response, List<RouteMatch> routeMatches) {
this.application = application;
this.request = request;
Expand Down Expand Up @@ -352,13 +354,21 @@ public String getMessage(String key, String language, Object... args) {
return application.getMessages().get(key, language, args);
}

@Override
public Route getRoute() {
return route;
}

@SuppressWarnings("unchecked")
protected void handleRoute(Route route) {
if (StringUtils.isNullOrEmpty(route.getName())) {
log.debug("Executing handler for {} '{}'", route.getRequestMethod(), route.getUriPattern());
} else {
log.debug("Executing '{}' for {} '{}'", route.getName(), route.getRequestMethod(), route.getUriPattern());
}

this.route = route;

route.getRouteHandler().handle(this);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,4 +126,6 @@ public interface RouteContext {

String getMessage(String key, String language, Object... args);

Route getRoute();

}

0 comments on commit 5350e79

Please sign in to comment.