middleware-helper
A library of connect/express middleware helper methods.
Example usage
Use methods defined in the library as middleware in a connect/express app to set up or end a request.
// Load dependencies.var middleware_helper = var express = var routes = { reslocalsresponse_datafoo = 'bar' // Status code defaults to 500 (internal server error) if not set. reslocalsstatus = 200 return } var app = appapp // Handle request for `/example_usage` HTTP endpoint, piecing together steps// in a flow for handling the request. The routes.example_usage_handler// method is responsible for business logic, while the middleware_helper// methods are responsible for preparing, formatting, and sending the response.app appconsole
When a request is received this results in an updated header.
HTTP/1.1 200 OKRequestID: 70ffc032c1b1537e11a5921d2005f277ff4aceffRequestTimer-Delta: 0Content-Type: application/json... { "foo": "bar"}
License
This repository is made available to the public as open source software under the MIT License.