pedestal

caleb.macdonaldblack 2019-05-25T06:33:17.000700Z

How do I serve static files?

caleb.macdonaldblack 2019-05-25T06:33:25.001Z

I can't really find much online

souenzzo 2019-05-25T13:32:45.001700Z

there is also ::file-path

👍 1
Ahmed Hassan 2019-05-29T05:51:55.006500Z

Which of these is used to serve JavaScript script files like main.js?

souenzzo 2019-05-29T12:12:20.007500Z

I output my main.js to somewhere like target/pubic/app/main.js then I set ::http/file-path to target/public In the index.html, you will import as <script src="/app/main.js"> Don't forget about ::http/mime-types mime/default-mime-types

✔️ 1
Ahmed Hassan 2019-05-29T12:31:11.007900Z

Bundle of thanks. It works. 🙂

Ahmed Hassan 2019-05-29T12:32:04.008100Z

When I change from ::http/file-path to ::http/resource-path it gives error again. What is difference here?

souenzzo 2019-05-29T13:28:24.008300Z

::http/resource-path needs to be something in your classpath. In :paths from deps.edn or :resource-paths from project.clj Example: output main.js in resource/public/app/main.js resource is in my classpath. I can test with (slurp (io/resource "public/app/main.js")) should return my file then I can use ::http/resource-path "public", my index with src="/app/main.js" ...

✔️ 1
souenzzo 2019-05-25T13:32:54.001900Z

@caleb.macdonaldblack