Middleware implementation

Note: middleware specified here have some difference w.r.t express middleware.
In express, we need to use a router middleware which actually does the routing.
Here, every thing is a middleware.