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
Routes in Pippo are created using methods named after HTTP verbs. For instance, in the previous example, we created a route to handle GET requests to the root of the website. You have a corresponding method in Application for all commonly used HTTP verbs (GET, POST, DELETE, HEAD, PUT). For a basic website, only GET and POST are likely to be used.
29
29
30
-
The route that is defined first takes precedence over other matching routes. So the ordering of routes is crucial to the behavior of an application.
30
+
The route that is defined first takes precedence over other matching routes. So the ordering of routes is crucial to the behavior of an application.
31
31
32
32
Each defined route has an __urlPattern__.
33
33
The route can be static or dynamic:
34
34
35
35
-`static` ("/", "/hello", "/contacts/1")
36
36
-`dynamic` (regex: "/.*" or parameterized: "/contact/{id}", "/contact/{id: [0-9]+}")
37
37
38
-
As you can see, it's easy to create routes with parameters. A parameter is wrapped by curly braces `{name}` and can optionally specify a regular expression.
38
+
As you can see, it's easy to create routes with parameters. A parameter is wrapped by curly braces `{name}` and can optionally specify a regular expression.
39
39
40
40
You can retrieve the path parameter value for a request in type safe mode using:
41
41
42
42
```java
43
43
GET("/contact/{id}", (routeContext) -> {
44
-
int id = routeContext.getParameter("id").toInt(0);
44
+
int id = routeContext.getParameter("id").toInt(0);
If you specify your parameter <u>without</u> a regex pattern, like the third example (e.g. `{id}`), the value of *id* will include your suffix unless you require the suffix using the pattern in the second example.
0 commit comments