snapframework / snap

Top-level package for the official Snap Framework libraries, includes the snaplets API as well as infrastructure for sessions, auth, and templates.

Home Page:http://snapframework.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Optimization for bracketHandler: skip acquire and release actions when they're not needed

kaol opened this issue · comments

I think bracketHandler could be more intelligent with regard to snaplets' behavior. Using it on Heist (for example) makes the acquire and release actions run for url patterns that it has no templates for and as such would never accept. It would never invoke any user splice code in such a case. Any reasonable pair of acquire and release actions should be a no op in such a case, besides wasting some resources. It would be a nice optimization for Snap for it to skip using them in such a case.

I'm not quite sure how to go about implementing something like this. A Handler, as a monad, is opaque to whether it would reject a particular url and by the time it returns empty the acquire action has been called already.