0.1.0 • Published 11 years ago
fun-chain v0.1.0
All aboard the fun train chain!
Pass arguments through a chain of functions. Each function must decide whether to continue through the chain.
var server = http.createServer(chain(
[ dispatch('get', '/oauth-callback', oauthCallbackAction)
, authenticateFromToken
, servePrivateFiles
, function(_,_, res) { notFound(res) }
]))
// ...
function authenticateFromToken(next, req, res) {
validateAuthToken(
authTokenFrom(req),
withErrHandler(handleAuthTokenErr, function(isValid) {
if (isValid) next(req, res) else redirectTo(res, oauth.authUrl(req.url))
})
})
}
// ...
function notFound(res) {
res.writeHead(404)
res.end("Not found\n")
}
It's like connect but without all the code
0.1.0
11 years ago