a simple netty HTTP server in clojure

Recently I’ve been toying with various clojure wrappers around java web servers. My goal is to write a small evented server that can queue up HTTP requests and then kick off some long-running processes.

The compojure stack is by far the cleanest, but it’s geared more
towards synchronous request/response cycles. I’d like to use
something like to EventMachine and saturnine seems the closest to
that goal. However, saturnine‘s current HTTP implementation is
lacking.

Now before I could contribute to saturnine I first needed to understand netty. If you’re trying to learn netty, I recommend you first read the users guide and then jump straight to the API docs on ChannelPipeline.

Next, I needed to write a basic HTTP server using netty. This post on StackOverflow and this sample code on netty’s website helped me get a basic HTTP server up an running.

Below is a a nieve translation of the netty sample code into clojure. Note that this is not listed here as an example of sexy clojure code, but rather a starting point for someone looking to get dirty with the netty libraries in clojure.

Search

Why, Hello!

I'm Nate Murray and this is a blog I've been writing since 2007.
I work at IFTTT and I've been working with big data data since 2009. My work involves large-scale data mining, distributed computing, iOS & web apps. If you like this blog then you should follow me on twitter. Follow @eigenjoy