1- """Middleware to remove BASE_PATH from incoming requests and update links in responses."""
1+ """Middleware to remove ROOT_PATH from incoming requests and update links in responses."""
22
33import logging
44from dataclasses import dataclass
@@ -15,26 +15,26 @@ class RemoveRootPathMiddleware:
1515 server.
1616
1717 IMPORTANT: This middleware must be placed early in the middleware chain (ie late in
18- the order of declaration) so that it trims the base_path from the request path before
18+ the order of declaration) so that it trims the root_path from the request path before
1919 any middleware that may need to use the request path (e.g. EnforceAuthMiddleware).
2020 """
2121
2222 app : ASGIApp
23- base_path : str
23+ root_path : str
2424 transform_links : bool = True
2525
2626 json_content_type_expr : str = r"application/(geo\+)?json"
2727
2828 async def __call__ (self , scope : Scope , receive : Receive , send : Send ) -> None :
29- """Remove BASE_PATH from the request path if it exists."""
29+ """Remove ROOT_PATH from the request path if it exists."""
3030 if scope ["type" ] != "http" :
3131 return await self .app (scope , receive , send )
3232
3333 path = scope ["path" ]
3434
35- # Remove base_path if it exists at the start of the path
36- if path .startswith (self .base_path ):
35+ # Remove root_path if it exists at the start of the path
36+ if path .startswith (self .root_path ):
3737 scope ["raw_path" ] = scope ["path" ].encode ()
38- scope ["path" ] = path [len (self .base_path ) :] or "/"
38+ scope ["path" ] = path [len (self .root_path ) :] or "/"
3939
4040 return await self .app (scope , receive , send )
0 commit comments