axum_test::util

Function spawn_serve

Source
pub fn spawn_serve<M, S>(
    tcp_listener: TcpListener,
    make_service: M,
) -> ServeHandle
where M: for<'a> Service<IncomingStream<'a>, Error = Infallible, Response = S> + Send + 'static, for<'a> <M as Service<IncomingStream<'a>>>::Future: Send, S: Service<Request, Response = Response, Error = Infallible> + Clone + Send + 'static, S::Future: Send,
Expand description

A wrapper around axum::serve() for tests, which spawns the service in a new thread.

The crate::util::ServeHandle returned will automatically attempt to terminate the service when dropped.