From 55a9023ca08852c83e1494f08771d740eabc1bd9 Mon Sep 17 00:00:00 2001 From: Jeremiah Senkpiel Date: Fri, 17 Jul 2020 09:00:05 -0700 Subject: [PATCH] Response: add From Allows you to do e.g. `Ok(NotFound)` from an Endpoint / Middleware. --- src/response.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/response.rs b/src/response.rs index 50e35254f..a03e1334f 100644 --- a/src/response.rs +++ b/src/response.rs @@ -398,6 +398,13 @@ impl From for Response { } } +impl From for Response { + fn from(status: StatusCode) -> Self { + let res: http::Response = status.into(); + res.into() + } +} + impl From for Response { fn from(s: String) -> Self { Body::from_string(s).into()