troute
super fast tiny router
install
$ npm install troute
usage
using troute
is super simple
;
you can use variable assignment in your route and capture their values in the req.params
object
;
api
troute(method, route, fn)
troute
accepts a valid http method, a string or RegExp
route, and a function fn(req, res, next)
as a callback
method
- a valid http methodroute
- a string orRegExp
for route matchingfn
- a callback function when the route is matched
see sregex for more information defining string and RegExp
routes
example
;
.get(route, fn)
matches all GET
requests
route
- a string orRegExp
for route matchingfn
- a callback function when the route is matched
example
troute;
.post(route, fn)
matches all POST
requests
route
- a string orRegExp
for route matchingfn
- a callback function when the route is matched
example
troute;
.put(route, fn)
matches all PUT
requests
route
- a string orRegExp
for route matchingfn
- a callback function when the route is matched
example
troute;
.del(route, fn)
matches all DELETE
requests
route
- a string orRegExp
for route matchingfn
- a callback function when the route is matched
example
troute;
.head(route, fn)
matches all HEAD
requests
route
- a string orRegExp
for route matchingfn
- a callback function when the route is matched
example
troute;
.options(route, fn)
matches all OPTIONS
requests
route
- a string orRegExp
for route matchingfn
- a callback function when the route is matched
example
trouteoptions'/videos' videosOptions;
license
MIT