connect-appender
Middleware to append some text to the body of outgoing responses.
Includes pre-filter and post-filter functions so that it doesn't have to buffer a request we don't care about, and can selectively append text based on the body of the response.
Example
The basic usage:
var connect = ;var appender = ;var app = ;
More advanced, choosing which request/responses to affect:
var connect = ;var appender = ; var { // called before the request is passed through // determines whether to wrap the resulting response return /only_here/;}; var { // called as the response is ending // determines whether to append the text return !/not_here/;}; var { // called to determine what text to append return 'zorz\n' + specstatusCode + '\n';}; // Spec is generated when ending the response, and looks like: {// request: http.ServerRequest,// response: http.ServerResponse,// statusCode: number,// headers: Object.<string, string>,// output: string// } var app = ;
TODOs
- response.write() with different encodings
Development
- init:
npm install
- tests:
npm test
- dev:
npm run-script tdd
NOTE: The tests rely on custom forks of: connect, grunt, and grunt-simple-mocha.