Created
May 31, 2014 15:44
-
-
Save deleteman/51bc77ae865f38fa57a5 to your computer and use it in GitHub Desktop.
Url specific pre processors on Vatican.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Current solution | |
var Vatican = require("vatican"); | |
var app = new Vatican(); | |
app.preprocessor(function(req, res, next) { | |
if(req.url.indexOf("/auth/unregister") != -1) { | |
//do the checks | |
if(error) next(error) | |
} | |
next(); | |
}); | |
//Possible solutions for 1.3 based on your question: | |
//For this solution, an array of path expressions can be passed, so the preprocessor will only be triggered when the current path matches one of the given posibilities | |
app.preprocessor(jwtCallback, ['/auth/unregister']); | |
//Another option is to have the @endpoint annotation have another option, like this: | |
//.. in your auth handler | |
@endpoint (url: /auth/unregister method: delete preprocessor: jwtCallback) | |
Auth.prototype.unregister = //.... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I like that idea!!! Thank you for the feedback!!