Function axum_debug::check_service [−][src]
pub fn check_service<S, ReqBody, ResBody>(_service: &S) where
S: Service<Request<ReqBody>, Response = Response<ResBody>> + Clone + Send + Sync + 'static,
S::Error: Into<Box<dyn Error + Send + Sync>> + Send,
S::Future: Send,
ReqBody: Send + 'static,
ResBody: Body<Data = Bytes> + Send + Sync + 'static,
ResBody::Error: Into<Box<dyn Error + Send + Sync>>,
Expand description
Checks if provided service can be used with Router
.
This function is useful when debugging a Service
.
Example
ⓘ
use axum::{handler::get, Router};
use axum_debug::{debug_handler, debug_router, check_service};
use tower::util::BoxService;
#[tokio::main]
async fn main() {
let service = BoxService::new(get(handler));
check_service(&service);
let app = Router::new().route("/", service);
debug_router!(app);
axum::Server::bind(&"0.0.0.0:3000".parse().unwrap())
.serve(app.into_make_service())
.await
.unwrap();
}
#[debug_handler]
async fn handler() -> &'static str {
"Hello, world!"
}
error[E0277]: the trait bound `BoxService<Request<_>, Response<...>, Infallible>: Clone` is not satisfied
--> main.rs:9:19
|
9 | check_service(&service);
| ^^^^^^^^ the trait `Clone` is not implemented for `BoxService<Request<_>, Response<...>, Infallible>`