Skip to content

Commit

Permalink
Fix logic missing
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryuga2967 committed Apr 17, 2024
1 parent 61cf725 commit ace645c
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,17 +77,21 @@ impl ProxyHttp for MyGateWay {
let not_found = Err(pingora_core::Error::new(pingora_core::ErrorType::Custom(
"Cannot found such container",
)));

let raw_path = std::str::from_utf8(&(session.req_header().raw_path()[1..])).unwrap();
let endpoint_key = match headers.get("X-Jaram-Container").map(|v| v.to_str()) {
Some(v) => match v {
Ok(v) => v,
Ok(v) => {
ctx.new_uri = match ("/".to_string() + raw_path).parse() {
Ok(uri) => Some(uri),
Err(_) => None,
};

v
}
Err(_) => return not_found,
},
None => {
let mut server_and_path =
std::str::from_utf8(&(session.req_header().raw_path()[1..]))
.unwrap()
.splitn(3, "/");
let mut server_and_path = raw_path.splitn(3, "/");

match server_and_path.next() {
Some(server) => {
Expand Down Expand Up @@ -160,10 +164,6 @@ impl ProxyHttp for MyGateWay {
.insert_header("Server", "MyGateWay")
.unwrap();

upstream_response
.insert_header("X-Forwarded-Path", ctx.host.to_owned())
.unwrap();

upstream_response.remove_header("alt-svc");
upstream_response.remove_header("X-Jaram-Container");

Expand Down

0 comments on commit ace645c

Please sign in to comment.