Function axum_debug::debug_service [−][src]
pub fn debug_service<S, ReqBody, ResBody>(service: S) -> 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 and returns 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, debug_service};
use tower::util::BoxService;
#[tokio::main]
async fn main() {
let service = BoxService::new(get(handler));
let app = Router::new().route("/", debug_service(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:54
|
9 | let app = Router::new().route("/", debug_service(service));
| ^^^^^^^ the trait `Clone` is not implemented for
`BoxService<Request<_>, Response<...>, Infallible>`