Skip to content

feat: web dynamic payload factory - #26

Merged
XucroYuri merged 4 commits into
mainfrom
goratio-dev-web-dynamic
Sep 3, 2026
Merged

feat: web dynamic payload factory#26
XucroYuri merged 4 commits into
mainfrom
goratio-dev-web-dynamic

Conversation

@XucroYuri

Copy link
Copy Markdown
Owner

web serve 支持 payload_factory,每次请求重新生成 HTML。

Copilot AI lite review requested due to automatic review settings September 3, 2026 00:28
@XucroYuri
XucroYuri merged commit 03bd56e into main Sep 3, 2026
11 checks passed
@XucroYuri
XucroYuri deleted the goratio-dev-web-dynamic branch September 3, 2026 00:29

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

make_dashboard_server() 允许 payloadpayload_factory 同时缺省会导致运行时崩溃,需要加入明确校验并修正已指出的问题。

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

该 PR 为 web serve 增加 payload_factory 支持,使本地只读 Web 工作台在每次请求时可重新生成 HTML,从而实现“真正的自动刷新”(而非仅刷新同一份静态 HTML)。

Changes:

  • 扩展 make_dashboard_server() / serve_dashboard():新增 payload_factory,按请求动态渲染页面
  • 新增单测覆盖 payload_factory 每次请求会被调用并反映在 HTML 中
  • 更新 Changelog 与 Roadmap 记录该能力与测试数量变化
File summaries
File Description
tests/test_web.py 新增测试验证 payload_factory 在多次请求中动态更新页面内容
src/goratio/web.py web serve 增加 payload_factory 入口并在请求处理时动态渲染 HTML
CHANGELOG.md 记录 web serve 新增 payload_factory 支持
.planning/ROADMAP.md Roadmap 勾选完成项并更新当前测试数量
Review details

Suppressed comments (1)

src/goratio/web.py:152

  • The handler encodes the HTML twice (once to compute Content-Length and again to write), which becomes more noticeable now that HTML may be regenerated per request. Encode once and reuse the bytes for both the length and write.
                html = current_html()
                self.send_response(200)
                self.send_header("Content-Type", "text/html; charset=utf-8")
                self.send_header("Content-Length", str(len(html.encode("utf-8"))))
                self.end_headers()
  • Files reviewed: 4/4 changed files
  • Comments generated: 2
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/goratio/web.py
Comment on lines 138 to +143
from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer

html = render_dashboard_html(payload, refresh_seconds=60)
def current_html():
if payload_factory is not None:
return render_dashboard_html(payload_factory(), refresh_seconds=60)
return render_dashboard_html(payload, refresh_seconds=60)
Comment thread tests/test_web.py
Comment on lines +78 to +81
def test_readonly_server_supports_payload_factory(self) -> None:
from goratio.web import make_dashboard_server

calls = {"n": 0}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants