File tree 1 file changed +8
-3
lines changed
1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -30,6 +30,8 @@ impl VssService {
30
30
}
31
31
}
32
32
33
+ const BASE_PATH_PREFIX : & str = "/vss" ;
34
+
33
35
impl Service < Request < Incoming > > for VssService {
34
36
type Response = Response < Full < Bytes > > ;
35
37
type Error = hyper:: Error ;
@@ -39,8 +41,11 @@ impl Service<Request<Incoming>> for VssService {
39
41
let store = Arc :: clone ( & self . store ) ;
40
42
let authorizer = Arc :: clone ( & self . authorizer ) ;
41
43
let path = req. uri ( ) . path ( ) . to_owned ( ) ;
44
+
42
45
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 {
44
49
"/getObject" => {
45
50
handle_request ( store, authorizer, req, handle_get_object_request) . await
46
51
} ,
@@ -54,10 +59,10 @@ impl Service<Request<Incoming>> for VssService {
54
59
handle_request ( store, authorizer, req, handle_list_object_request) . await
55
60
} ,
56
61
_ => {
57
- let error = format ! ( "Unknown request: {}" , path) . into_bytes ( ) ;
62
+ let error_msg = "Invalid request path." . as_bytes ( ) ;
58
63
Ok ( Response :: builder ( )
59
64
. status ( StatusCode :: BAD_REQUEST )
60
- . body ( Full :: new ( Bytes :: from ( error ) ) )
65
+ . body ( Full :: new ( Bytes :: from ( error_msg ) ) )
61
66
. unwrap ( ) )
62
67
} ,
63
68
}
You can’t perform that action at this time.
0 commit comments