before
Allows for customized handler execution chains. It will be invoked before the actual handler.
before("GET", "*", (req, rsp) -> );
}
}
You are allowed to modify the request and response objects.
Please note that the
before
handler is just syntax sugar for
Route.Filter.
For example, the
before
handler was implemented as:
use("GET", "*", (req, rsp, chain) -> );
}
}
A
before
handler must to be registered before the actual handler you want to
intercept.
before("GET", "/path", (req, rsp) -> );
get("/path", req ->
// your code goes here
return ...;
});
}
}
If you reverse the order then it won't work.
Remember: routes are executed in the order they are defined and the pipeline
is executed as long you don't generate a response.