DioxusLabs / DioxusLabs/dioxus
`serve_router` should accept `impl ToSocketAddrs` (or a `impl axum::serve::listener::Listener`)
- Dominant language
- Rust
- Stars
- 39.1k
- Forks
- 1.9k
- Avg merge
- 4d 10h
- Merged PRs (30d)
- 4
Description
## Feature Request
In my current application (that I'm converting to dioxus) I do the following to support both IPv4 and IPv6:
```rust
let addrs = [
SocketAddr::V4(SocketAddrV4::new(Ipv4Addr::UNSPECIFIED, port)),
SocketAddr::V6(SocketAddrV6::new(Ipv6Addr::UNSPECIFIED, port, 0, 0)),
];
let addrs: &[SocketAddr] = &addrs;
// run our app with hyper, listening globally on port 3000
let listener = tokio::net::TcpListener::bind(addrs).await?;
```
Dioxus requires me to pass in a single `SocketAddr` which means I have to pick. This has lead to some rather confusing situations where (testing a container image) `localhost:PORT` doesn't work, but `127.0.0.1:PORT` does.
## Implement Suggestion
Probably the best non-breaking solution would be to create a new `serve_listener` (or somesuch) that accepts a `axum::serve::listener::Listener`. That's what axum itself requires, and I don't see a good reason not to simply surface that, given that dioxus already have a heavy dependency on axum. Then rewrite `serve_router` to be a simple wrapper around this new function for backwards compatibility reasons.
This should be rather simple to do. I'm willing to contribute a PR if wanted.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.