Attaching Express to an existing node http server.

1,097 views
Skip to first unread message

August Lilleaas

unread,
Jun 1, 2011, 7:35:22 PM6/1/11
to Express
Hi,

I have an application that does some low level HTTP stuff, so I
already have a http server running, via http.createServer - regular
node.js stuff, in other words.

Reading the docs, I can only find examples of Express spawning its own
HTTP server. I want to attach express to this HTTP server. Can it be
done?

Laurie Harper

unread,
Jun 2, 2011, 10:31:29 AM6/2/11
to expre...@googlegroups.com
Should just be a case of wrapping your http.Server instance as a
middleware:

var svr = http.createServer();
var app = express.createServer();
app.use(svr);
// regular express setup follows....

L.

> --
> You received this message because you are subscribed to the Google
> Groups "Express" group.
> To post to this group, send email to expre...@googlegroups.com.
> To unsubscribe from this group, send email to express-js
> +unsub...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/
> group/express-js?hl=en.
>

--
Laurie Harper

Reply all
Reply to author
Forward
0 new messages