Files
NebulaShell/store/@{FutureOSS}/http-tcp/router.py
Falck f894e55602 清理冗余路由代码,修复首页标题与模板安全
- 简化 http-api/http-tcp/web-toolkit 的 router.py,抽取重复代码
- 修复 ws-api middleware 中间件返回值传递问题
- 修复 web-toolkit template.py 安全漏洞 (eval → AST 验证)
- 将首页标题从 "OSS Runtime" 改为 "Future OSS"
- 更新 README.md 与 static/banner.svg
- 新增 i18n 国际化插件 (骨架)
- 新增 oss/shared/ 共享模块
2026-04-06 12:40:49 +08:00

22 lines
652 B
Python

"""TCP HTTP 路由器"""
from typing import Callable, Optional, Any
from oss.shared.router import BaseRouter, match_path
class TcpRouter(BaseRouter):
"""TCP HTTP 路由器"""
def handle(self, request: dict) -> dict:
"""处理请求"""
method = request.get("method", "GET")
path = request.get("path", "/")
result = self.find_route(method, path)
if result:
route, params = result
# 将路径参数注入到请求中
request["path_params"] = params
return route.handler(request)
return {"status": 404, "headers": {}, "body": "Not Found"}