@@ -210,11 +210,24 @@ def _reset_app_cache_marker(self):
210210 to all the running instances.
211211 """
212212
213+ @api .model
214+ def get_endpoint (self , root_path ):
215+ # try to match the request url with the most similar endpoint
216+ endpoints_by_length = self .search ([]).sorted (
217+ lambda fe : len (fe .root_path ), reverse = True
218+ )
219+ endpoint = False
220+ while endpoints_by_length :
221+ candidate_endpoint = endpoints_by_length [0 ]
222+ if root_path .startswith (candidate_endpoint .root_path ):
223+ endpoint = candidate_endpoint
224+ break
225+ endpoints_by_length -= candidate_endpoint
226+ return endpoint or None
227+
213228 @api .model
214229 def get_app (self , root_path ):
215- record = self .search ([("root_path" , "=" , root_path )])
216- if not record :
217- return None
230+ record = self .get_endpoint (root_path )
218231 app = FastAPI ()
219232 app .mount (record .root_path , record ._get_app ())
220233 self ._clear_fastapi_exception_handlers (app )
@@ -238,7 +251,7 @@ def _clear_fastapi_exception_handlers(self, app: FastAPI) -> None:
238251 @api .model
239252 @tools .ormcache ("root_path" )
240253 def get_uid (self , root_path ):
241- record = self .search ([( " root_path" , "=" , root_path )] )
254+ record = self .get_endpoint ( root_path )
242255 if not record :
243256 return None
244257 return record .user_id .id
0 commit comments