aboutsummaryrefslogtreecommitdiffstats
path: root/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs24
1 files changed, 12 insertions, 12 deletions
diff --git a/src/main.rs b/src/main.rs
index 5f6b574..b55999b 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,5 +1,5 @@
use hyper::service::{make_service_fn, service_fn};
-use hyper::{Body, Client, Request, Response, Server, StatusCode, header::HeaderValue};
+use hyper::{header::HeaderValue, Body, Client, Request, Response, Server};
use std::env;
use std::net::SocketAddr;
use toml;
@@ -23,22 +23,22 @@ async fn upstream_req(
Client::new().request(upstream_req).await?
}
Err(other) => Response::builder()
- .status(StatusCode::INTERNAL_SERVER_ERROR)
+ .status(other.http_status_code())
.header("Content-Type", "application/json; charset=UTF-8")
- .body(serde_json::to_string(&other.to_json()).unwrap().into())
+ .body(
+ serde_json::to_string(&other.to_json_value())
+ .unwrap()
+ .into(),
+ )
.unwrap(),
};
- resp.headers_mut().insert(
- "Via",
- HeaderValue::from_static("es-public-proxy"),
- );
+ resp.headers_mut()
+ .insert("Via", HeaderValue::from_static("1.1 es-public-proxy"));
if config.enable_cors == Some(true) {
+ resp.headers_mut()
+ .insert("Access-Control-Allow-Origin", HeaderValue::from_static("*"));
resp.headers_mut().insert(
- "Access-Control-Allow-Origin",
- HeaderValue::from_static("*"),
- );
- resp.headers_mut().insert(
- "Access-Control-Allow-Origin",
+ "Access-Control-Allow-Methods",
HeaderValue::from_static("GET, POST, DELETE, HEAD, OPTIONS"),
);
resp.headers_mut().insert(