Hi all,

I have created a simple HTTP to 0MQ proxy [1] written in 150 lines of Lua 
code.  It uses the async. HTTP server & 0MQ socket handlers from my lua-
handlers [2] project.

When a HTTP POST request is received it allocates a unique request id and 
sends the POST data to a XREQ socket with a message envelope so that it can 
route the responses from the XREQ socket back to the correct HTTP client.  It 
would be very easy to add the HTTP request/response headers to the 0MQ 
messages by adding a JSON part to the messages.

To try it out run the proxy with:
lua examples/http_zmq_proxy.lua tcp://localhost:1080/ tcp://127.0.0.1:5555

then start a backend XREP server on port 5555:
lua examples/zmq_xrep_server.lua

then send a simple POST request:
curl -d "test 1" "http://localhost:1080/";

1. https://github.com/Neopallium/lua-
handlers/blob/master/examples/http_zmq_proxy.lua
2. https://github.com/Neopallium/lua-handlers

-- 
Robert G. Jakabosky
_______________________________________________
zeromq-dev mailing list
[email protected]
http://lists.zeromq.org/mailman/listinfo/zeromq-dev

Reply via email to