svenstaro/miniserve

Unix domain socket

Opened this issue · 6 comments

I have a proxy in front of miniserve. I was hoping I can pass through the requests/responses via a domain socket but I only see a -p port option.

Can miniserve listen on a domain socket?

Seems like a good idea. Probably should be an argument to -p. Should be easy to implement. Wanna take a stab at this?

Sure. You thinking something like miniserve -p 8080 and miniserve -p /tmp/web.socket both being valid?

Or do you want something like miniserve -p 8080 and miniserve -p unix:///tmp/web.socket?

I think probably the first one. The most important thing here is to check that the file doesn't already exist so that users don't accidentally nuke their own files. Apart from that, it should be pretty straight forward.

Are you okay with using miniserve -i /tmp/web.socket (--interfaces flag instead)? I think it might be more appropriate and it fits the code better.

Oh yeah that might work as well. I think technically speaking it's a bit less correct. Perhaps it might be less confusing to have a different flag altogether, like --socket, -s? Perhaps we could also combine -i and -p into --socket to support stuff like -s 127.0.0.1:8080 -s /tmp/web.socket -s 0.0.0.0:8000. Currently we do not support listening on multiple different ports which might be cool?

EDIT: Might also be cool to support shortcuts this way: -s 127.0.0.1 would use the default port 8080 and -s :8080 would use the default interface 0.0.0.0.

Let's have a short discussion here as it'll be a major change. :)

I think #935 is about as much time as I can invest right now. Please let me know what you think.

EDIT: Might also be cool to support shortcuts this way: -s 127.0.0.1 would use the default port 8080 and -s :8080 would use the default interface 0.0.0.0.

That would be cool but I am a little concerned as it requires you to learn an (albeit simple) syntax to listen on an ip and port.
-i 0.0.0.0 -p 80 is very intuitive to me vs -s :80 less so.