racker/falcon — pull request #268 by swistakm (2014-05-20 16:20:30+00:00)
Title: [Feature] resource aware global before hooks

Make before hooks aware of affected resource by adding temporary `"resource"` key in `params` parameter. This parameter won't be propagated to resource method to assert compatibility with already existing resources.

**Rationale**: this change is intended to ease creating more descriptive and declarative resources. Hooks are first place to look for when creating authentication/authorization solutions. Authorization almost always depends on resource and thus it would be very helpful to have information about resource in authorization middleware.

Good example would be an OAuth (1.0/2.0) where there is an concept of "scopes" or "realms". Good OAuth middleware should allow declarations like this:
```
class Resource(object):
realms_allowed = ['admin', 'editor', 'viewer']

@realms('viewer')
def on_get(req, resp):
pass
```
With this feature it will be easier to implement more sophisticated auth middlewares.