@@ -265,7 +265,7 @@ def __init__(
265
265
cors : Optional [CORSConfig ] = None ,
266
266
debug : Optional [bool ] = None ,
267
267
serializer : Optional [Callable [[Dict ], str ]] = None ,
268
- prefix : Optional [str ] = None ,
268
+ strip_prefixes : Optional [List [ str ] ] = None ,
269
269
):
270
270
"""
271
271
Parameters
@@ -279,8 +279,8 @@ def __init__(
279
279
environment variable
280
280
serializer : Callable, optional
281
281
function to serialize `obj` to a JSON formatted `str`, by default json.dumps
282
- prefix: str, optional
283
- optional prefix removed from the path before doing the routing
282
+ strip_prefixes: List[ str] , optional
283
+ optional list of prefixes to be removed from the path before doing the routing
284
284
"""
285
285
self ._proxy_type = proxy_type
286
286
self ._routes : List [Route ] = []
@@ -290,7 +290,7 @@ def __init__(
290
290
self ._debug = resolve_truthy_env_var_choice (
291
291
env = os .getenv (constants .EVENT_HANDLER_DEBUG_ENV , "false" ), choice = debug
292
292
)
293
- self ._prefix = prefix
293
+ self ._strip_prefixes = strip_prefixes
294
294
295
295
# Allow for a custom serializer or a concise json serialization
296
296
self ._serializer = serializer or partial (json .dumps , separators = ("," , ":" ), cls = Encoder )
@@ -541,8 +541,11 @@ def _resolve(self) -> ResponseBuilder:
541
541
542
542
def _remove_prefix (self , path : str ) -> str :
543
543
"""Remove the configured prefix from the path"""
544
- if self ._prefix and path .startswith (self ._prefix ):
545
- return path [len (self ._prefix ) :]
544
+ if self ._strip_prefixes :
545
+ for prefix in self ._strip_prefixes :
546
+ if path .startswith (prefix + "/" ):
547
+ return path [len (prefix ) :]
548
+
546
549
return path
547
550
548
551
def _not_found (self , method : str ) -> ResponseBuilder :
0 commit comments