9

I'm new to clojure and compojure and I was wondering if there's a way to do a hot reload of code changes as you can with Ruby's Sinatra (with the shotgun gem) or Java's Play!

I'm following along with this Heroku tutorial so if there's a way to do it with the foreman gem that would work too.

thanks!

kreek
  • 8,774
  • 8
  • 44
  • 69

2 Answers2

7

Take a look at this SOq:

and this tutorial:

The suggestion is to use ring's reload middleware.

Community
  • 1
  • 1
icyrock.com
  • 27,952
  • 4
  • 66
  • 85
2

Recent versions of Compojure make it even easier by incorporating all of the middleware into a single function call:

https://github.com/weavejester/compojure/wiki/Getting-Started

In particular...

(require '[compojure.handler as handler])

; define my-routes in here as normal
(handler/site my-routes)

I'm using some of this in my own projects. It works well, but I'll switch back to choosing ring middleware directly if I decide that I need to add or remove anything.

Dave Liepmann
  • 1,555
  • 1
  • 18
  • 22
Savanni D'Gerinel
  • 2,379
  • 17
  • 27