axum/routing/
not_found.rs
1use crate::response::Response;
2use axum_core::response::IntoResponse;
3use http::{Request, StatusCode};
4use std::{
5 convert::Infallible,
6 future::ready,
7 task::{Context, Poll},
8};
9use tower_service::Service;
10
11#[derive(Clone, Copy, Debug)]
16pub(super) struct NotFound;
17
18impl<B> Service<Request<B>> for NotFound
19where
20 B: Send + 'static,
21{
22 type Response = Response;
23 type Error = Infallible;
24 type Future = std::future::Ready<Result<Response, Self::Error>>;
25
26 #[inline]
27 fn poll_ready(&mut self, _cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
28 Poll::Ready(Ok(()))
29 }
30
31 fn call(&mut self, _req: Request<B>) -> Self::Future {
32 ready(Ok(StatusCode::NOT_FOUND.into_response()))
33 }
34}