mirror of
https://github.com/actix/actix-extras.git
synced 2024-11-28 01:32:57 +01:00
use build_response method
This commit is contained in:
parent
b693d5491b
commit
a255a6fb69
@ -626,8 +626,8 @@ impl Responder for &'static str {
|
|||||||
type Item = HttpResponse;
|
type Item = HttpResponse;
|
||||||
type Error = Error;
|
type Error = Error;
|
||||||
|
|
||||||
fn respond_to(self, _: HttpRequest) -> Result<HttpResponse, Error> {
|
fn respond_to(self, req: HttpRequest) -> Result<HttpResponse, Error> {
|
||||||
Ok(HttpResponse::Ok()
|
Ok(req.build_response(StatusCode::OK)
|
||||||
.content_type("text/plain; charset=utf-8")
|
.content_type("text/plain; charset=utf-8")
|
||||||
.body(self))
|
.body(self))
|
||||||
}
|
}
|
||||||
@ -645,8 +645,8 @@ impl Responder for &'static [u8] {
|
|||||||
type Item = HttpResponse;
|
type Item = HttpResponse;
|
||||||
type Error = Error;
|
type Error = Error;
|
||||||
|
|
||||||
fn respond_to(self, _: HttpRequest) -> Result<HttpResponse, Error> {
|
fn respond_to(self, req: HttpRequest) -> Result<HttpResponse, Error> {
|
||||||
Ok(HttpResponse::Ok()
|
Ok(req.build_response(StatusCode::OK)
|
||||||
.content_type("application/octet-stream")
|
.content_type("application/octet-stream")
|
||||||
.body(self))
|
.body(self))
|
||||||
}
|
}
|
||||||
@ -664,8 +664,8 @@ impl Responder for String {
|
|||||||
type Item = HttpResponse;
|
type Item = HttpResponse;
|
||||||
type Error = Error;
|
type Error = Error;
|
||||||
|
|
||||||
fn respond_to(self, _: HttpRequest) -> Result<HttpResponse, Error> {
|
fn respond_to(self, req: HttpRequest) -> Result<HttpResponse, Error> {
|
||||||
Ok(HttpResponse::Ok()
|
Ok(req.build_response(StatusCode::OK)
|
||||||
.content_type("text/plain; charset=utf-8")
|
.content_type("text/plain; charset=utf-8")
|
||||||
.body(self))
|
.body(self))
|
||||||
}
|
}
|
||||||
@ -683,8 +683,8 @@ impl<'a> Responder for &'a String {
|
|||||||
type Item = HttpResponse;
|
type Item = HttpResponse;
|
||||||
type Error = Error;
|
type Error = Error;
|
||||||
|
|
||||||
fn respond_to(self, _: HttpRequest) -> Result<HttpResponse, Error> {
|
fn respond_to(self, req: HttpRequest) -> Result<HttpResponse, Error> {
|
||||||
Ok(HttpResponse::Ok()
|
Ok(req.build_response(StatusCode::OK)
|
||||||
.content_type("text/plain; charset=utf-8")
|
.content_type("text/plain; charset=utf-8")
|
||||||
.body(self))
|
.body(self))
|
||||||
}
|
}
|
||||||
@ -702,8 +702,8 @@ impl Responder for Bytes {
|
|||||||
type Item = HttpResponse;
|
type Item = HttpResponse;
|
||||||
type Error = Error;
|
type Error = Error;
|
||||||
|
|
||||||
fn respond_to(self, _: HttpRequest) -> Result<HttpResponse, Error> {
|
fn respond_to(self, req: HttpRequest) -> Result<HttpResponse, Error> {
|
||||||
Ok(HttpResponse::Ok()
|
Ok(req.build_response(StatusCode::OK)
|
||||||
.content_type("application/octet-stream")
|
.content_type("application/octet-stream")
|
||||||
.body(self))
|
.body(self))
|
||||||
}
|
}
|
||||||
@ -721,8 +721,8 @@ impl Responder for BytesMut {
|
|||||||
type Item = HttpResponse;
|
type Item = HttpResponse;
|
||||||
type Error = Error;
|
type Error = Error;
|
||||||
|
|
||||||
fn respond_to(self, _: HttpRequest) -> Result<HttpResponse, Error> {
|
fn respond_to(self, req: HttpRequest) -> Result<HttpResponse, Error> {
|
||||||
Ok(HttpResponse::Ok()
|
Ok(req.build_response(StatusCode::OK)
|
||||||
.content_type("application/octet-stream")
|
.content_type("application/octet-stream")
|
||||||
.body(self))
|
.body(self))
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@ use serde::de::DeserializeOwned;
|
|||||||
|
|
||||||
use error::{Error, JsonPayloadError, PayloadError};
|
use error::{Error, JsonPayloadError, PayloadError};
|
||||||
use handler::{Responder, FromRequest};
|
use handler::{Responder, FromRequest};
|
||||||
|
use http::StatusCode;
|
||||||
use httpmessage::HttpMessage;
|
use httpmessage::HttpMessage;
|
||||||
use httprequest::HttpRequest;
|
use httprequest::HttpRequest;
|
||||||
use httpresponse::HttpResponse;
|
use httpresponse::HttpResponse;
|
||||||
@ -71,10 +72,10 @@ impl<T: Serialize> Responder for Json<T> {
|
|||||||
type Item = HttpResponse;
|
type Item = HttpResponse;
|
||||||
type Error = Error;
|
type Error = Error;
|
||||||
|
|
||||||
fn respond_to(self, _: HttpRequest) -> Result<HttpResponse, Error> {
|
fn respond_to(self, req: HttpRequest) -> Result<HttpResponse, Error> {
|
||||||
let body = serde_json::to_string(&self.0)?;
|
let body = serde_json::to_string(&self.0)?;
|
||||||
|
|
||||||
Ok(HttpResponse::Ok()
|
Ok(req.build_response(StatusCode::OK)
|
||||||
.content_type("application/json")
|
.content_type("application/json")
|
||||||
.body(body))
|
.body(body))
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user