midmare-http-router
v1.1.1
Published
midmare http router lib
Downloads
8
Readme
const { createServer } = require('http');
const { default: mid } = require('midmare');
const { Router: { HttpRouter, delegateHttp } } = require('midmare-http-router');
// HTTP ROUTER
const app = mid();
const httpRouter = new HttpRouter();
// Use named function declaration to
httpRouter.process('/', function get(ctx) {
ctx.status = 200;
ctx.body = { ololo:1 };
});
app.use(httpRouter).init();
// Be sure that you use `delegateHttp` on app.
// delegateHttp make app understand that at some moment you will get request response object. And it will be injected to context.
createServer(delegateHttp(app)).listen(3000);