/ src / root.rs
root.rs
 1  use std::{
 2      convert::Infallible,
 3      pin::Pin,
 4      task::{Context, Poll},
 5  };
 6  
 7  use axum::{
 8      http::Request,
 9      response::{IntoResponse, Response},
10  };
11  use http::StatusCode;
12  use tower::Service;
13  
14  #[derive(Clone, Default)]
15  pub struct Root {}
16  
17  impl<Req> Service<Request<Req>> for Root {
18      type Response = Response;
19  
20      type Error = Infallible;
21  
22      type Future = Pin<Box<dyn Future<Output = Result<Self::Response, Self::Error>> + Send>>;
23  
24      fn poll_ready(&mut self, _context: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
25          Poll::Ready(Ok(()))
26      }
27  
28      fn call(&mut self, _request: Request<Req>) -> Self::Future {
29          let response = StatusCode::NOT_FOUND.into_response();
30  
31          Box::pin(async { Ok(response) })
32      }
33  }