I have tried to convert a leiningen project to boot: https://github.com/borkdude/lein2boot.
It uses the serve task to serve a handler. The handler offers an API and also serves files. Using the reload task, I want to be able to reload javascript.
I needed to place my html and javascript at the root of a resources directory (in this example "assets"), because the reload task sends changed javascript to the browser using the full resource path (/main.js
).
This means I also have to serve the root of my classpath: (resources "/" {:root ""})
in Compojure. The problem with this is that anyone can request any file from my entire classpath: no good.
When I relocate the javascript to assets/public/main.js
and serve from the public directory: (resources "/" {:root "public"})
, the file can be requested at "/main.js", but the reload task notifies the browser to reload a file from "/public/main.js" which causes a 404.
How can I solve this problem?
It looks like this is being worked on in https://github.com/adzerk-oss/boot-reload/issues/18, but will eventually allow an
:asset-path
option to provide relative roots.