Server for handling login's information.
(
tx: UnboundedSender<Result<AppPassword, Error>>,
)
| 84 | |
| 85 | /// Server for handling login's information. |
| 86 | pub async fn server( |
| 87 | tx: UnboundedSender<Result<AppPassword, Error>>, |
| 88 | ) -> (impl Future<Output = Result<(), std::io::Error>>, u16) { |
| 89 | let app = Router::new().route("/", get(|body| request(body, tx))); |
| 90 | let addr = SocketAddr::V4(SocketAddrV4::new(Ipv4Addr::LOCALHOST, 0)); |
| 91 | let listener = TcpListener::bind(addr).await.unwrap_or_else(|e| { |
| 92 | panic!("error binding to {}: {}", addr, e); |
| 93 | }); |
| 94 | let port = listener.local_addr().unwrap().port(); |
| 95 | let server = axum::serve(listener, app.into_make_service()); |
| 96 | |
| 97 | (server.into_future(), port) |
| 98 | } |
no test coverage detected