Attach custom HTTP headers to the response when an error occurs. #572
This commit is contained in:
parent
528a908f95
commit
7771d4e08f
|
@ -169,9 +169,9 @@ impl Responder for Response {
|
|||
if let Some(cache_control) = self.0.cache_control().value() {
|
||||
res.header("cache-control", cache_control);
|
||||
}
|
||||
for (name, value) in self.0.http_headers() {
|
||||
res.header(name, value);
|
||||
}
|
||||
}
|
||||
for (name, value) in self.0.http_headers() {
|
||||
res.header(name, value);
|
||||
}
|
||||
futures_util::future::ok(res.body(serde_json::to_string(&self.0).unwrap()))
|
||||
}
|
||||
|
|
|
@ -214,9 +214,9 @@ impl<'r> Responder<'r, 'static> for Response {
|
|||
if let Some(cache_control) = self.0.cache_control().value() {
|
||||
response.set_header(Header::new("cache-control", cache_control));
|
||||
}
|
||||
for (name, value) in self.0.http_headers() {
|
||||
response.adjoin_header(Header::new(name.to_string(), value.to_string()));
|
||||
}
|
||||
}
|
||||
for (name, value) in self.0.http_headers() {
|
||||
response.adjoin_header(Header::new(name.to_string(), value.to_string()));
|
||||
}
|
||||
|
||||
response.set_sized_body(body.len(), Cursor::new(body));
|
||||
|
|
|
@ -164,9 +164,9 @@ pub fn respond(resp: impl Into<async_graphql::BatchResponse>) -> tide::Result {
|
|||
if let Some(cache_control) = resp.cache_control().value() {
|
||||
response.insert_header(headers::CACHE_CONTROL, cache_control);
|
||||
}
|
||||
for (name, value) in resp.http_headers() {
|
||||
response.append_header(name, value);
|
||||
}
|
||||
}
|
||||
for (name, value) in resp.http_headers() {
|
||||
response.append_header(name, value);
|
||||
}
|
||||
response.set_body(Body::from_json(&resp)?);
|
||||
Ok(response)
|
||||
|
|
|
@ -85,12 +85,11 @@ impl Reply for BatchResponse {
|
|||
resp.headers_mut().insert("cache-control", value);
|
||||
}
|
||||
}
|
||||
for (name, value) in self.0.http_headers() {
|
||||
if let (Ok(name), Ok(value)) =
|
||||
(TryInto::<HeaderName>::try_into(name), value.try_into())
|
||||
{
|
||||
resp.headers_mut().append(name, value);
|
||||
}
|
||||
}
|
||||
for (name, value) in self.0.http_headers() {
|
||||
if let (Ok(name), Ok(value)) = (TryInto::<HeaderName>::try_into(name), value.try_into())
|
||||
{
|
||||
resp.headers_mut().append(name, value);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user