dbrain / soggy

An fast and simple express/sinatra like web framework.. thing.. for Go.
45 stars 1 forks source link

Route validation/extra steps #4

Closed dbrain closed 12 years ago

dbrain commented 12 years ago

As some gangster attempting to use soggy, I'd like to verify no b*tches be hitting my secret resources with a pre and maybe post handler for a route. I'm not entirely sure how this should work.. but maybe something like: server.Get('/lies', [ aRouteHandler, bRouteHandler ]) where aRouteHandler could be a reused function and could call Next to continue or error out / show forbidden.. if its ok call Next to go to bRouteHandler? Whatever makes sense without butchering performance or making life sloppy.

dbrain commented 12 years ago

This is done, you can now add multiple routes to a single path e.g. server.Get("/admin", adminOnly, theRouteHandler)

Both parameters take the same format, adminOnly should call *soggy.Context.Next(nil) to continue or write an error.