Kemal: How to change the path of where the assets inside `public_folder` are being served on the HTTP server?

Title, I have a public folder with the assets of my project and they are served and accessed using http://127.0.0.1:8080/<some_file_on_public_folder>, however, I can’t find a way to change the path of where those files are being server on the HTTP server, I would like to serve the files of public_folder but on something like http://127.0.0.1:8080/public/<some_file_on_public_folder>. Is that possible with the current version of Kemal (1.7.1)? Because I couldn’t find a way :/

You can use the public_folder helper.

public_folder "path/to/your/folder"

For more info Kemal - Guide

Uhhh, that doesn’t make it. I just want to change the http path from where the public_folder is being served, because by default, they are served on the root of the website.

So let’s say, the public folder looks like this:

public
└── favicon.ico

By default it can be accessed on http://127.0.0.1:8080/favicon.ico. I want to change that to http://127.0.0.1:8080/assets/favicon.ico or http://127.0.0.1:8080/static/favicon.ico or whatever. Is that possible?

The assets folder is always mounted at the root path. There is no way to configure something else.

You could consider a workaround: Move the assets into a folder structure that represent the mount path: Instead of placing favicon.ico directly into #{public_folder}, put it into #{public_folder}/static/favicon.ico. Then it’ll be served at /static/favicon.ico.

Another option would be to inject a middleware handler that strips off the mount prefix, i.e. transforms the resource /static/favicon.ico into /favicon.ico.

Would be cool if that was configurable somehow.

Cool, that worked, thanks!