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
I'd like to apply a filter on certain methods. I have an authorization filter which I'd like to only work on GET and POST methods. The solution is not to add that check within the authorization method itself, but I feel that is much uglier.
How it has to be now:
Future<bool> filterAuth(HttpRequest r) {...}
...
var router = new Router(server)
..filter(new RegExp(r'/auth/.*'), (HttpRequest r) {
if (r.method != 'OPTIONS') {
return filterAuth(r);
}
return new Future.value(true);
})
...
The cleaner solution:
var router = new Router(server)
..filter(new RegExp(r'/auth/.*'), methods: ['GET', 'POST'], filterAuth);
The text was updated successfully, but these errors were encountered:
I'd like to apply a filter on certain methods. I have an authorization filter which I'd like to only work on GET and POST methods. The solution is not to add that check within the authorization method itself, but I feel that is much uglier.
How it has to be now:
The cleaner solution:
The text was updated successfully, but these errors were encountered: