Skip to content

Commit fd36e99

Browse files
authored
Merge pull request #45 from G8XSU/strip-base
Strip BASE_PREFIX from request path.
2 parents 37fe9ae + e476d8d commit fd36e99

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

rust/server/src/vss_service.rs

+8-3
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ impl VssService {
3030
}
3131
}
3232

33+
const BASE_PATH_PREFIX: &str = "/vss";
34+
3335
impl Service<Request<Incoming>> for VssService {
3436
type Response = Response<Full<Bytes>>;
3537
type Error = hyper::Error;
@@ -39,8 +41,11 @@ impl Service<Request<Incoming>> for VssService {
3941
let store = Arc::clone(&self.store);
4042
let authorizer = Arc::clone(&self.authorizer);
4143
let path = req.uri().path().to_owned();
44+
4245
Box::pin(async move {
43-
match path.as_str() {
46+
let prefix_stripped_path = path.strip_prefix(BASE_PATH_PREFIX).unwrap_or("");
47+
48+
match prefix_stripped_path {
4449
"/getObject" => {
4550
handle_request(store, authorizer, req, handle_get_object_request).await
4651
},
@@ -54,10 +59,10 @@ impl Service<Request<Incoming>> for VssService {
5459
handle_request(store, authorizer, req, handle_list_object_request).await
5560
},
5661
_ => {
57-
let error = format!("Unknown request: {}", path).into_bytes();
62+
let error_msg = "Invalid request path.".as_bytes();
5863
Ok(Response::builder()
5964
.status(StatusCode::BAD_REQUEST)
60-
.body(Full::new(Bytes::from(error)))
65+
.body(Full::new(Bytes::from(error_msg)))
6166
.unwrap())
6267
},
6368
}

0 commit comments

Comments
 (0)