How can I access a route or group metadata from within an interceptor?
I would like to add a @public() to a route like:
@app.Route("/user/find/:id")
@public()
getUser(String id) => {"name": "User", "login": "user"};
And create an interceptor that blocks the access to the routes that do not have the public metadata and there is no logged user. Is this possible?
@app.Interceptor(r'/admin/.*')
adminFilter() {
if (app.request.session["username"] != null || CURRENT_ROUTE_HAS_PUBLIC_METADATA) {
return app.chain.next();
} else {
return app.chain.abort(HttpStatus.UNAUTHORIZED);
//or app.chain.redirect("/login.html");
}
}