You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: _posts/2015-05-05-routes.md
+38-2Lines changed: 38 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -110,6 +110,8 @@ If you specify your parameter <u>without</u> a regex pattern, like the third exa
110
110
across a large number of routes without needing to define this attribute on each individual route.
111
111
Also you can add (route) filters for all routes of the group.
112
112
113
+
The `RouteGroup` is a concept very import when you are forced to deal with a considerable number of routes in your application.
114
+
113
115
The below snippet defines a `UserRoutes` group:
114
116
115
117
```java
@@ -146,6 +148,40 @@ public class PippoApplication extends Application {
146
148
147
149
You can access the routes defined in `UserRoutes` using something like `http://localhost:8338/user/1` (retrieve the user with _id_ equals with 1).
148
150
149
-
You can see a more complex example in [Matilda](https://github.com/decebals/matilda/blob/master/src/main/java/ro/fortsoft/matilda/PippoApplication.java#L108) (a real life application built with Pippo).
150
-
151
+
Pippo has support for __NESTED GROUPS__.
152
+
The idea is that you can create completely decoupled routes groups. Using nested routes groups you can create a nice modular application.
153
+
154
+
```java
155
+
classDemoApplicationextendsApplication {
156
+
157
+
@Override
158
+
protectedvoidonInit() {
159
+
addRouteGroup(newAdminRoutes());
160
+
}
161
+
162
+
}
163
+
164
+
classAdminRoutesextendsRouteGroup {
165
+
166
+
publicAdminRoutes() {
167
+
super("/admin");
151
168
169
+
// BEFORE FILTERS
170
+
addBeforeFilters();
171
+
172
+
// ROUTES
173
+
addRoutes();
174
+
175
+
// GROUPS
176
+
addRouteGroup(newUserRoutes());
177
+
addRouteGroup(newCustomerRoutes());
178
+
}
179
+
180
+
}
181
+
```
182
+
183
+
In above snippet I added (in DemoApplication) `AdminRoutes` as route group which contains `UserRoutes` and `CustomerRoutes` as child routes groups.
184
+
I don't need to know when I create a RouteGroup where the group will be mount. For example I can have a modular web application where each plugin comes with own independent routes (user management -> `UserRoutes`, customer management -> `CustomerRoutes`).
185
+
186
+
You can see a more complex example in [Matilda](https://github.com/decebals/matilda/blob/master/src/main/java/ro/fortsoft/matilda/PippoApplication.java#L108) (a real life application built with Pippo).
0 commit comments