the-http-router
v1.0.0
Published
router for the-http
Downloads
15
Readme
The HTTP Router
Router for the-http.
Install
npm install --save the-http-routerUsage
const {listen} = require(
const route = require('the-http-router')
const hanlder = route([
['GET', '/hello' () => Response.withTextBody('hello world')],
[['GET', POST'], '/hi/:name', (request) => Response.withTextBody(`hi ${request.params.name}`),
])
listen(3000)(handler)API
route(routes, options?)
{Array} routes- item is [method, path, handler]handleris THHandlerrequest.paramsis added to hold route params- see find-my-way to learn more about
methodandpath
{Object} [options]{function} [options.defaultHandler]
