satori-python-server 0.17.3__tar.gz → 0.17.5__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: satori-python-server
3
- Version: 0.17.3
3
+ Version: 0.17.5
4
4
  Summary: Satori Protocol SDK for python, specify server part
5
5
  Home-page: https://github.com/RF-Tar-Railt/satori-python
6
6
  Author-Email: RF-Tar-Railt <rf_tar_railt@qq.com>
@@ -27,7 +27,7 @@ classifiers = [
27
27
  "Programming Language :: Python :: 3.12",
28
28
  "Operating System :: OS Independent",
29
29
  ]
30
- version = "0.17.3"
30
+ version = "0.17.5"
31
31
 
32
32
  [project.license]
33
33
  text = "MIT"
@@ -96,6 +96,7 @@ exclude = [
96
96
  "exam_qps.py",
97
97
  "exam1.py",
98
98
  "exam2.py",
99
+ "src/satori/_vendor/*",
99
100
  ]
100
101
 
101
102
  [tool.ruff.lint]
@@ -308,17 +308,27 @@ class Server(Service, RouterMixin):
308
308
  self_id: str = request.headers.get("X-Self-ID") or request.headers.get("Satori-User-ID") # type: ignore
309
309
 
310
310
  for _router in self._adapters:
311
- if action not in _router.routes:
311
+ if action in _router.routes:
312
+ func = _router.routes[action]
313
+ elif action.startswith("internal") and "internal/*" in _router.routes:
314
+ func = _router.routes["internal/*"]
315
+ else:
312
316
  continue
313
317
  if not _router.ensure(platform, self_id):
314
318
  continue
315
- return await _request_handler(action, request, _router.routes[action], platform, self_id)
319
+ return await _request_handler(action, request, func, platform, self_id)
316
320
  if action in self.routes:
317
321
  return await _request_handler(action, request, self.routes[action], platform, self_id)
322
+ if action.startswith("internal") and "internal/*" in self.routes:
323
+ return await _request_handler(action, request, self.routes["internal/*"], platform, self_id)
318
324
  for _router in self.routers:
319
- if action not in _router.routes:
325
+ if action in _router.routes:
326
+ func = _router.routes[action]
327
+ elif action.startswith("internal") and "internal/*" in _router.routes:
328
+ func = _router.routes["internal/*"]
329
+ else:
320
330
  continue
321
- return await _request_handler(action, request, _router.routes[action], platform, self_id)
331
+ return await _request_handler(action, request, func, platform, self_id)
322
332
  return Response(status_code=404, content=action)
323
333
 
324
334
  async def proxy_url_handler(self, request: StarletteRequest):
@@ -22,7 +22,11 @@ class Adapter(Service, RouterMixin):
22
22
  server: "Server"
23
23
 
24
24
  @abstractmethod
25
- def get_platform(self) -> str: ...
25
+ def get_platform(self) -> str:
26
+ """该方法仅用于自动标识适配器类型
27
+
28
+ 若你继承该类并且重写了 `id`, 该方法可以返回任意字符串
29
+ """
26
30
 
27
31
  @abstractmethod
28
32
  def ensure(self, platform: str, self_id: str) -> bool: ...