tower_web/response/
option.rs

1use super::{Context, Response, Serializer};
2use http::status::StatusCode;
3
4use http;
5
6impl<T: Response> Response for Option<T> {
7    type Buf = T::Buf;
8    type Body = T::Body;
9
10    fn into_http<S: Serializer>(self, context: &Context<S>) -> Result<http::Response<Self::Body>, ::Error> {
11        match self {
12            Some(inner) => Response::into_http(inner, context),
13            None => Err(StatusCode::NOT_FOUND.into()),
14        }
15    }
16}