I've created a project using Luminus with the following command:
lein new luminus myapp +mysql +kee-frame +swagger +oauth +kibit
In this project I created an API call that calls a function to read a file from disk. The API Call (partly):
{:get {:summary "Returns a file from disk to show in GUI"
:responses {200 {:body ::val/my-file}}
:handler (constantly
{:status 200
:body (gui/get-file)})}}
The function get-file is in the namespace myapp.db.gui-related and looks like this:
(defn get-file
[]
(log/info "Trying to retrieve file")
(read-string (slurp "file.edn")))
When I start a REPL and enter the command (mount/start)
the application starts normally and I can make the API call to see the content of the file. The file location is now in the root of my project.
However, if I place the file in resources/myapp and change the slurp command to either (slurp "myapp/file.edn")
or (slurp "resources/myapp/file.edn")
, I get an error after running (mount/start)
and the application is not started.
I get the same error if I try to read a file with an absolute path like (slurp "C:\\Development\\file.edn")
2020-04-30 12:02:03,512 [nREPL-session-88d31cf8-b119-4a87-901d-3eee1eb61cc7] INFO myapp.env --=[myapp started successfully using the development profile]=-
2020-04-30 12:02:03,607 [nREPL-session-88d31cf8-b119-4a87-901d-3eee1eb61cc7] INFO myapp.db.gui-related - Trying to retrieve file
Execution error (ConnectException) at java.net.DualStackPlainSocketImpl/connect0 (DualStackPlainSocketImpl.java:-2).
Connection refused: connect
In this project I'll have a lot of 'config' files to read and I would like to be able to place them in one or more sub folders in the root of my project. Besides this there will be another file to be read in, which will be outside the folder structure of my application.
How can I read these files?