There’s a lot of variation in Clojure web stacks at the moment. Some people like frameworks, others like to roll their own. What do you use?
I tend to use Jetty. But if I need async connections (websockets, etc) I guess I would choose http-kit. I haven’t had much use for async yet, though I may in the near future.
I like to keep it close to the metal. I use Ring, obviously.
I like Hiccup for HTML generation.
I also tend to use Liberator, because of all the heavy lifting it does to serve correct HTTP responses.
I put as much work as possible into middleware so that code in the handler is as much domain logic as possible. Also, I try to use middleware in one big stack (as opposed to separate stacks specific to different routes) so that it creates a standardized request that I can learn and use throughout the app.
I stay away from frameworks like Noir. They are rarely the way that makes sense to me, so they don’t provide much value. It’s easy to set up your own stack, so why use an existing one?
playnice looks really nice. I think there’s a bunch of room for alternative Ring routers–Compojure is a bit complex for my taste. I’ve written my own janky one as well that gives you a nested tree of resources like this: https://gist.github.com/anonymous/6124107f09c2b900d22b
HTML generation still seems like an unsolved problem. I’m trying an unholy combination of Enlive + Hiccup but am somewhat dissatisfied with it. I met someone at the Bay Area Clojure Meetup who spoke very positively about Om, but that’s generating Enlive fully in the web client.
I’m still hunting around for good toolkits for things like auth–there seem to only be a few around, and they seem either too simple or too complex.
Are y’all deploying straight Jetty from lein, or is the whole WAR/application container deployment thing the way go? I’m coming from Python/Ruby-land where these things are unknown–I think I deploy a WAR to tomcat once in college, and it was a pain.
There’s another Ring router working its way around.
What I like about Ring and its ecosystem is that it’s quite straightforward to roll your own. There’s no need for a monolithic solution. Plenty of libraries are good enough (in a good way).
I like Hiccup for HTML. It’s fast and easily composable. I’ve used Enlive and built some cool stuff on top of it. But I don’t like writing straight HTML, so I avoid it.
I try not to use an application container. I used one for a long time on Amazon’s Elastic Beanstalk (it’s managed Tomcat). Tomcat is still a pain. But now, I build uberwars with Jetty. Configuration is done in the environment or command line (for the port). I don’t know why you’d want more than that.