Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryuga2967 committed Apr 16, 2024
1 parent 33cae0a commit ea30e19
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .entries.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{
"name": "test",
"address": "127.0.0.1",
"port": 8000,
"port": 4123,
"is_ssl": false,
"headers": []
},
Expand Down
40 changes: 21 additions & 19 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,26 +84,28 @@ impl ProxyHttp for MyGateWay {
Err(_) => return not_found,
},
None => {
let mut server_and_path = std::str::from_utf8(session.req_header().raw_path())
.unwrap()
.splitn(3, "/");

server_and_path.next().unwrap();

let server = match server_and_path.next() {
Some(server) => server,
let mut server_and_path =
std::str::from_utf8(&(session.req_header().raw_path()[1..]))
.unwrap()
.splitn(3, "/");

match server_and_path.next() {
Some(server) => {
if server.len() == 0 {
"haksul-proxy"
} else {
ctx.new_uri = match server_and_path.next() {
Some(path) => match ("/".to_string() + path).parse() {
Ok(uri) => Some(uri),
Err(_) => None,
},
None => Some(Uri::from_static("/")),
};
server
}
}
None => "haksul-proxy",
};

ctx.new_uri = match server_and_path.next() {
Some(path) => match ("/".to_string() + path).parse() {
Ok(uri) => Some(uri),
Err(_) => None,
},
None => Some(Uri::from_static("/")),
};

server
}
}
};

Expand Down

0 comments on commit ea30e19

Please sign in to comment.