Skip to content

Commit

Permalink
Add protected constructor in Route that facilitates the injection of …
Browse files Browse the repository at this point in the history
…dependencies
  • Loading branch information
decebals committed Dec 1, 2021
1 parent 0d9f14e commit 0f3e788
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions pippo-core/src/main/java/ro/pippo/core/route/Route.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,30 @@ public class Route {

private Map<String, Object> attributes;

/**
* Used in subclasses (facilitates the injection of dependencies).
* <pre>{@code
* @Component
* public class LogRoute extends Route implements RouteHandler {
*
* public LogRoute() {
* super(HttpConstants.Method.GET, "/log");
*
* setRouteHandler(this);
* }
*
* @Override
* public void handle(RouteContext routeContext) {
* // do something
* }
*
* }
* }</pre>
*/
protected Route(String requestMethod, String uriPattern) {
this(requestMethod, uriPattern, routeContext -> {});
}

public Route(String requestMethod, String uriPattern, RouteHandler routeHandler) {
this.requestMethod = requestMethod;
this.uriPattern = uriPattern;
Expand Down

0 comments on commit 0f3e788

Please sign in to comment.