-
Notifications
You must be signed in to change notification settings - Fork 40
Serving files
Juho Teperi edited this page Jun 21, 2016
·
4 revisions
- https://github.com/pandeiro/boot-http
- Recommended solution is to serve the files directly from classpath:
(serve)
- (it is the default option)
- No need to use
target
task - Why this works:
- Boot tasks write resulting files to their temp dirs
- Task commits the files to fileset
- Boot adds the files to classpath
- Very short version of why this is good idea:
- The state of target directory is unknown when Boot is running. It is mainly intended to be used to write build artifacts (JARs).
- Target directory is shared state, when using it you can't run several processes using the same dir. Classpath is separate for each process.
Use resource-handler / Compojure resources route to serve files from classpath.
https://github.com/Deraen/saapas/blob/master/src/clj/backend/server.clj#L14-L15
Take care of the classpath prefix (:root
) when or if you are using the same code in production. The classpath probably contains files you don't want to be globally accessible.