Function serve
fn serve<L, M, S>(listener: L, make_service: M) -> Serve<L, M, S>
where
L: Listener,
M: for<'a> Service<IncomingStream<'a, L>, Error = std::convert::Infallible, Response = S>,
S: Service<axum_core::extract::Request, Response = axum_core::response::Response, Error = std::convert::Infallible> + Clone + Send + 'static,
<S as >::Future: Send
Serve the service with the supplied listener.
This method of running a service is intentionally simple and doesn't support any configuration. Use hyper or hyper-util if you need configuration.
It supports both HTTP/1 as well as HTTP/2.
Examples
Serving a Router:
use ;
# async ;
See also Router::into_make_service_with_connect_info.
Serving a MethodRouter:
use get;
# async ;
See also MethodRouter::into_make_service_with_connect_info.
Serving a Handler:
use HandlerWithoutStateExt;
# async ;
See also HandlerWithoutStateExt::into_make_service_with_connect_info and
HandlerService::into_make_service_with_connect_info.
Return Value
Although this future resolves to io::Result<()>, it will never actually complete or return an
error. Errors on the TCP socket will be handled by sleeping for a short while (currently, one
second).