@@ -67,17 +67,20 @@ fn query_field_get_bool(req: &Request<'_>, field_name: &str) -> bool {
6767#[ macro_export]
6868macro_rules! prpc_routes {
6969 ( $state: ty, $handler: ty) => { {
70- ra_rpc:: declare_prpc_routes!( prpc_post, prpc_get, $state, $handler) ;
70+ $crate:: prpc_routes!( $state, $handler, trim: "" )
71+ } } ;
72+ ( $state: ty, $handler: ty, trim: $trim_prefix: literal) => { {
73+ $crate:: declare_prpc_routes!( prpc_post, prpc_get, $state, $handler, trim: $trim_prefix) ;
7174 rocket:: routes![ prpc_post, prpc_get]
7275 } } ;
7376}
7477
7578#[ macro_export]
7679macro_rules! declare_prpc_routes {
77- ( $post: ident, $get: ident, $state: ty, $handler: ty) => {
78- $crate:: declare_prpc_routes!( path: "/<method>" , $post, $get, $state, $handler) ;
80+ ( $post: ident, $get: ident, $state: ty, $handler: ty, trim : $trim_prefix : literal ) => {
81+ $crate:: declare_prpc_routes!( path: "/<method>" , $post, $get, $state, $handler, trim : $trim_prefix ) ;
7982 } ;
80- ( path: $path: literal, $post: ident, $get: ident, $state: ty, $handler: ty) => {
83+ ( path: $path: literal, $post: ident, $get: ident, $state: ty, $handler: ty, trim : $trim_prefix : literal ) => {
8184 #[ rocket:: post( $path, data = "<data>" ) ]
8285 async fn $post<' a: ' d, ' d>(
8386 state: & ' a $crate:: rocket_helper:: deps:: State <$state>,
@@ -90,6 +93,7 @@ macro_rules! declare_prpc_routes {
9093 . request( rpc_request)
9194 . method( method)
9295 . data( data)
96+ . method_trim_prefix( $trim_prefix)
9397 . build( )
9498 . handle:: <$handler>( )
9599 . await
@@ -105,6 +109,7 @@ macro_rules! declare_prpc_routes {
105109 . state( & * * state)
106110 . request( rpc_request)
107111 . method( method)
112+ . method_trim_prefix( $trim_prefix)
108113 . build( )
109114 . handle:: <$handler>( )
110115 . await
@@ -184,6 +189,7 @@ pub struct PrpcHandler<'s, 'r, S> {
184189 state : & ' s S ,
185190 request : RpcRequest < ' r > ,
186191 method : & ' r str ,
192+ method_trim_prefix : Option < & ' r str > ,
187193 data : Option < Data < ' r > > ,
188194}
189195
@@ -263,8 +269,10 @@ pub async fn handle_prpc_impl<S, Call: RpcCall<S>>(
263269 state,
264270 request,
265271 method,
272+ method_trim_prefix,
266273 data,
267274 } = args;
275+ let method = method. trim_start_matches ( method_trim_prefix. unwrap_or_default ( ) ) ;
268276 let remote_app_id = request
269277 . certificate
270278 . as_ref ( )
0 commit comments