README
The HTTP Router
Router for the-http.
Install
npm install --save the-http-router
Usage
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]