mirror of
https://github.com/fafhrd91/actix-web
synced 2025-08-31 17:07:01 +02:00
introduce custom FromRequest traint for conversion into Reply
This commit is contained in:
@@ -3,8 +3,7 @@
|
||||
use http::StatusCode;
|
||||
|
||||
use body::Body;
|
||||
use route::Reply;
|
||||
use route::RouteHandler;
|
||||
use route::{Reply, RouteHandler, FromRequest};
|
||||
use httprequest::HttpRequest;
|
||||
use httpresponse::{HttpResponse, HttpResponseBuilder};
|
||||
|
||||
@@ -74,6 +73,12 @@ impl<S> RouteHandler<S> for StaticResponse {
|
||||
}
|
||||
}
|
||||
|
||||
impl FromRequest for StaticResponse {
|
||||
fn from_request(self, _: HttpRequest) -> Reply {
|
||||
Reply::response(HttpResponse::new(self.0, Body::Empty))
|
||||
}
|
||||
}
|
||||
|
||||
impl From<StaticResponse> for HttpResponse {
|
||||
fn from(st: StaticResponse) -> Self {
|
||||
st.response()
|
||||
|
Reference in New Issue
Block a user