You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 29, 2019. It is now read-only.
varhttp=require('http');varpassage=require('passage');varsequenz=require('sequenz');varserver=http.createServer(sequenz(passage.any('*',function(req,res,next){console.log('i got called for any method and any url');next();}),passage.get('/',function(req,res,next){res.end('i got called for GET /');}),passage.any('/users*',function(req,res,next){console.log('i got called for an url that starts with /users with any method');next();passage.get('/users/:userId/posts/:postId',function(req,res,next,params){res.end('i got called for GET /users/'+params.userId+'/posts/'+params.postId);}),passage.post('/users/:userId/posts',function(req,res,next,params){res.end('i got called for POST /users/'+params.userId+'/posts/');}),passage.put('/users/:userId/posts/:postId',function(req,res,next,params){res.end('i got called for PUT /users/'+params.userId+'/posts/'+params.postId);}),passage.patch('/users/:userId/posts/:postId',function(req,res,next,params){res.end('i got called for PATCH /users/'+params.userId+'/posts/'+params.postId);}),passage.delete('/users/:id',function(req,res,next,params){res.end('i got called for DELETE /users/'+params.id);})));server.listen(80);
sequenz takes an array of middlewares
and returns a single middleware that runs the middlewares in order.
the first argument to the passage functions can by any url-pattern.
vhost example
varhttp=require('http');varconnect=require('connect');varpassage=require('passage');varsequenz=require('sequenz');varroutes=sequenz(passage.vhost('alice.example.com',connect.static('public/alice')),passage.vhost('bob.example.com',connect.static('public/bob')),passage.vhost(':sub.example.com',function(req,res,next,params){console.log('i got called for '+params.sub+'.example.com');next(););server=http.createServer(routes);server.listen(80);