package
write services that attach to existing httpServer instances
npm install http-attachGitHub-flavored package documentation.
Across all versions, last 30 days.
3,220 in 30 days
Runtime metadata.
Tagged topics.
Registry package owners.
write services that attach to existing httpServer instances
Let's say you want to write a small module of functionality - responding to a single http route, for example - and want to give the module a way to register itself without depending on a specific framework, like connect, express, or hapi.
This lets you implement functionality like socket.io's `socketio.attach(httpServer)``
var httpAttach = require('http-attach')
function middleware (req, res, next) {
console.log('this middleware is neat & useful')
next()
}
middleware.attach = function (httpServer) {
httpAttach(httpServer, middleware)
}
module.exports = middlewarehttpServer should be an HttpServer or HttpsServer instance.
This replaces the existing request event handler so you can additional control point for your program logic. You can yield to the existing handler by calling the next() function you get as the third argument, like connect-style middleware.
If there is no existing request handler, calling next() will end the request with a 404 status code.
$ npm install http-attachFrom package root:
$ npm install
$ npm testApache 2.0. (c) 2016 Zendesk, Inc. See LICENSE.md