server/rest.rs: use a protocol extension to avoid double log
Instead of modifying the response header itself.
This commit is contained in:
parent
7e03988caf
commit
7171b3e079
|
@ -60,7 +60,7 @@ pub struct ApiService {
|
||||||
impl ApiService {
|
impl ApiService {
|
||||||
fn log_response(path: &str, resp: &Response<Body>) {
|
fn log_response(path: &str, resp: &Response<Body>) {
|
||||||
|
|
||||||
if resp.headers().contains_key("PBS_PROXIED") { return; }
|
if resp.extensions().get::<NoLogExtension>().is_some() { return; };
|
||||||
|
|
||||||
let status = resp.status();
|
let status = resp.status();
|
||||||
|
|
||||||
|
@ -154,6 +154,8 @@ fn get_request_parameters_async(
|
||||||
Box::new(resp)
|
Box::new(resp)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct NoLogExtension();
|
||||||
|
|
||||||
fn proxy_protected_request(
|
fn proxy_protected_request(
|
||||||
info: &'static ApiMethod,
|
info: &'static ApiMethod,
|
||||||
mut parts: Parts,
|
mut parts: Parts,
|
||||||
|
@ -175,7 +177,7 @@ fn proxy_protected_request(
|
||||||
.request(request)
|
.request(request)
|
||||||
.map_err(|e| Error::from(e))
|
.map_err(|e| Error::from(e))
|
||||||
.map(|mut resp| {
|
.map(|mut resp| {
|
||||||
resp.headers_mut().insert("PBS_PROXIED", header::HeaderValue::from_static("1"));
|
resp.extensions_mut().insert(NoLogExtension);
|
||||||
resp
|
resp
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue