svenstaro/miniserve

Feature request: Redirect support

adrianrudnik opened this issue · 2 comments

I am currently using miniserve to host a simple, static, multilingual website without any scripts. The one feature I'm really missing is redirect file support with Accept-Language handling. Is this something you could see within the scope of this server?

Idea would be a simple .redirect file in the root that is read on startup. Example content could be

/permalink/pp de /de/datenschutz/ 302
/permalink/pp * /en/privacy-policy/ 301
  • First parameter is the static part of the URL path to match against, must match exactly.
  • Second parameter is the Accept-Language header matching intersections (like de-de going to the de part), but fallback to the * choice. If not fallback is defined, the least amount of logic should happen, 404.
  • Third parameter would be the destination for the HTTP Location header.
  • Fourth parameter could be the HTTP status code to send back.

Not sure if you see a benefit in this, so I wanted to ask. In a prototype I'm currently building, I'm facing the problem of providing a link to legal documents that can be in multiple languages, and I can only define a single link that spans all languages. I could also see some benefit later for hard redirects of outdated content pages, and before diving into another convoluted nginx setup, I thought about this project.

Not much I can provide in terms of Rust code as its not my main language, but I would support the idea with a 50€ one-time sponsor.

I'm not sure how I feel about this. Especially the file-based redirects might get really confusing. Also might be a security problem if people upload those files. I guess you could filter it but it's just more stuff to keep in mind. I don't really want miniserve to be a fully-featured webserver.

Chances are, people that need redirects also need to run logic for those redirects and that'll slide us right down the slippery feature creep slope. For instance, in your case I'd probably go for Caddy.

Thoughts?

Thats fine! I'll go with Caddy or something similar for now, the upload topic could introduce new problems, yes.