ravine
v0.1.2
Published
ravine is a simple router middleware for nodejs
Downloads
1
Readme
ravine
ravine is a simple router middleware for nodejs
with ravine routes are just javascript arrays. use javascript array manipulation functions to construct and manipulate routes.
install
npm install ravine
use
http = require 'http'
ravine = require 'ravine'
middleware = ravine [
['ALL', '*', (req, res, next) ->
# called before all following routes
next()
]
['GET', '/', (req, res, next) ->
# called only on GET /
res.end 'hello'
]
['ALL', '/users*', (req, res, next) ->
# called before all following routes if the request url starts with /users
next()
]
['POST', '/users', (req, res, next) ->
res.end 'posted'
]
['PUT', '/users/:id', (req, res, next) ->
# called for example on PUT /users/7 - req.params will then be {id: 7}
next()
]
['DELETE', '/users/:id', (req, res, next) ->
# called for example on DELETE /users/18 - req.params will then be {id: 18}
next()
]
]
server = http.createServer middleware
server.listen 80
see url-pattern for supported url patterns.
the parameters extracted from the url will be available as req.params
.