redstone-dart / redstone

A metadata driven microframework for Dart.
http://redstone-dart.github.io/redstone
MIT License
342 stars 42 forks source link

Execution order of plugins #84

Closed cgarciae closed 9 years ago

cgarciae commented 9 years ago

I have two plugins: Catch and Private; they are both implemented around a addRouteWrapper. Catch catches errors and returns them as a String inside a custom Resp object. Private checks for some auth parameters in the headers and verifies them in mongodb. A typical use case would be

@app.Route ('/someRoute')
@Catch()
@Private()
@Encode()
somePrivateSafeRoute() {...}

I noticed that depending on how I order the decorator tags the end result is different, more specifically, the one at the bottom is executed first. Is this accurrate or just coincidence? I'd like Private to always authenticate before the route is executed and Catch to catch errors after the route is executed.

luizmineo commented 9 years ago

The API doesn't guarantees any specific execution order. If you run this code in v0.6, for example, you will get a different result, since it has a different implementation.

cgarciae commented 9 years ago

Thanks, will program according to this.