reitit

agorgl 2025-03-21T10:22:09.379019Z

Hello there! I noticed that the resource/file handlers of reitit serve index files with redirects, so I made a little PR with an additional option to also allow serving them directly: https://github.com/metosin/reitit/pull/725! I'm now searching for a way to avoid serving index files when no trailing slash exists (e.g. /sample should not serve /sample/index.html but /sample/ should) is there already something for this or should I make another PR?

opqdonut 2025-03-21T10:33:36.104689Z

there's a redirect-based approach to slashes: https://github.com/metosin/reitit/blob/master/doc/ring/slash_handler.md

opqdonut 2025-03-21T10:34:22.630089Z

I'll try to find time to look at the PR at some point

agorgl 2025-03-21T10:37:02.613179Z

yes this approach is for treating paths without slashes the same as paths with slashes, e.g. when we need /sample to serve the same thing as /sample/

agorgl 2025-03-21T10:38:55.075779Z

The above for some reason seems to be the default functionality for resource/file handlers when serving index files which is in my opinion counter-intuitive (given the explicitness of paths in regular router)

agorgl 2025-03-21T10:40:19.521739Z

I would expect when having a /sample/ resource/asset directory the /sample to return 404 and /sample/ to return the matching index e.g. /sample/index.html (if we look at it semantically also, 'indexes' are for directories)

agorgl 2025-03-21T10:40:37.657129Z

now both /sample and /sample/ return /sample/index.html

agorgl 2025-03-21T16:32:52.103419Z

I made a branch that implements the above functionality too and will contribute in a separate PR as soon as the above PR merges to avoid conflicts 🙂