1-
2-
3-
4-
5-
61![ Java Express Logo] ( https://image.ibb.co/mCdxtm/java_express.png )
72
83Small clone of the node-js express framework written in pure Java 8.
9-
104[ ![ License MIT] ( https://img.shields.io/badge/License-MIT-blue.svg )] ( https://choosealicense.com/licenses/mit/ )
115
126# Getting Started
@@ -32,10 +26,11 @@ Default is localhost, so you can access, without setting the hostname, only from
3226Quick reference:
3327* [ URL Basics] ( #url-basics )
3428 * [ URL Parameter] ( #url-parameter )
29+ * [ URL Parameter Listener] ( #url-parameter-listener )
3530 * [ URL Querys] ( #url-querys )
3631 * [ Cookies] ( #cookies )
3732 * [ Form Data] ( #form-data )
38- * [ HTTP - Request and Response object ] ( #http---request-and-response-object )
33+ * [ HTTP - Request and Response] ( #http---request-and-response-object )
3934 * [ Response Object] ( #response-object )
4035 * [ Request Object] ( #request-object )
4136* [ Middleware] ( #middleware )
@@ -57,6 +52,21 @@ app.get("/posts/:user/:description", (req, res) -> {
5752});
5853```
5954
55+ ### URL Parameter Listener
56+ You can also add an event listener when the user called an route which contains an certain parameter:
57+ ``` java
58+ app. get(" /posts/:user/:id" , (req, res) - > {
59+ // Code
60+ });
61+ ```
62+ For example, if we want to check every ` id ` before the associated get post etc. handler will be fired, we can use the ` app.onParam([PARAM]) ` function:
63+ ``` java
64+ app. onParam(" id" , (req, res) - > {
65+ // Do something with the id parameter, eg. check if it's valid.
66+ });
67+ ```
68+ Now, this function will be called every time when an context is requested which contains the ` id ` parameter placeholder.
69+
6070## URL Querys
6171If you make an request which contains querys, you can access the querys over ` req.getQuery(NAME) ` .
6272
0 commit comments