hyperlocal icon indicating copy to clipboard operation
hyperlocal copied to clipboard

Server example doesn't use hyperlocal?

Open stevenengler opened this issue 1 year ago • 5 comments

This may just be a misunderstanding on my part, but hyperlocal advertises itself using (emphasis added):

Hyper is a rock solid Rust HTTP client and server toolkit. [...] hyperlocal builds on and complements Hyper's interfaces for building Unix domain socket HTTP clients and servers.

Later in the README it gives a server example at examples/server.rs, but this example doesn't even seem to use hyperlocal. So I don't understand why hyperlocal advertises itself as being a server toolkit, while the server example doesn't use hyperlocal. This leaves me (as someone seeing the library for the first time) confused about what this project actually is or what it does.

stevenengler avatar Apr 26 '24 20:04 stevenengler

I agree, I'm not sure if this library is needed now with hyper v1. My Rust project used hyperlocal before hyper v1 and we found that to be necessary for listening on UDS. However hyper v1 now seems to support binding to a UDS perfectly fine, it's just not documented (attempts at getting it documented were rejected here and here). The original server example pre-hyper v1 used itself, but now after the hyper v1 update to hyperlocal, all mentions of hyperlocal were removed in the server example.

x86pup avatar Apr 26 '24 21:04 x86pup

The original server example pre-hyper v1 used itself, but now after the hyper v1 update to hyperlocal, all mentions of hyperlocal were removed in the server example.

Ah okay, that makes sense. I guess this issue can be about updating the documentation to explain the current status, as it's not very clear without knowing the historical background.

However hyper v1 now seems to support binding to a UDS perfectly fine, it's just not documented (attempts at getting it documented were rejected here and here).

As an aside, one thing that the approaches in the examples above don't support is setting file permissions on the unix socket before binding, which is useful for security. Maybe this library could provide a convenience method for that, which is a bit of a pain to do manually (create non-blocking unix socket, fchmod, bind, listen, and an extra chmod) as the process can be platform-dependent.

stevenengler avatar Apr 28 '24 20:04 stevenengler

This may just be a misunderstanding on my part

You're not misunderstanding anything @stevenengler - this appears to be a documentation update oversight on my part when I made the changes to support hyper v1. At that time, the hyper service constructor functions that existed in 0.x where no longer present in 1.x.

You can see their old use in the old hyperlocal server example here: https://github.com/softprops/hyperlocal/blob/2ee4d149644600d326559af0d2b235c945b05c04/examples/server.rs#L2

That "example" as you noticed, is no longer a demonstration of hyperlocal and now is effectively support infrastructure for the client example (you can run the server "example" to see help how the client example functions).

iamjpotts avatar Jun 10 '24 02:06 iamjpotts

As an aside, one thing that the approaches in the examples above don't support is setting file permissions on the unix socket before binding, which is useful for security. Maybe this library could provide a convenience method for that, which is a bit of a pain to do manually (create non-blocking unix socket, fchmod, bind, listen, and an extra chmod) as the process can be platform-dependent.

I am not the maintainer of this repo, but I imagine the maintainer would welcome such a PR.

iamjpotts avatar Jun 10 '24 02:06 iamjpotts

Server example doesn't use hyperlocal

As-of a few minutes ago, there's now a rewritten server adapter in main and an example on how to use it.

iamjpotts avatar Jun 11 '24 00:06 iamjpotts

closing this for now. the server example has changed because hyper has changed. it now serves as a driver for running the client example which assumes a server listening in order to run

softprops avatar Jul 22 '24 14:07 softprops