jondubois / nombo

Node.js Realtime App Framework

Home Page:http://nombo.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Split router into separate caching, routing, compressing and responding middleware layers

jondubois opened this issue · comments

Instead of letting the router handle all these aspects, split it into multiple middleware layers.

The flow of a request should be something like this:

(req, res) >> userDefinedMiddleware(req, res) >> respondFromCache(req, res) >> rout(req, res) >> gzip(req, res) >> respond(req, res)

Each middleware will need to decorate the req object with pending response data after the request has passed through it. Once the final respond() middleware is reached, the response will be sent.