mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2026-11-08 19:56:53 +00:00
feat(web-svc-translate): answer the canonical root with the documentation
The gateway defined no route for /, so FastAPI answered its own canonical
domain with a JSON 404. Its only browser surface is /docs, which the proxy
already injects logout.js into, so the universal-logout spec read an empty
surface and failed on a role whose logout wiring was in fact correct.
web-opt-rdr-domains opts out of the tor contract as a surfaceless role
(c4e64656be). That shape does not fit here: this gateway has a surface, it was
just not where its canonical URL pointed.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
110d415e71
commit
90c448c747
1 file changed
+5
-1
@@ -5,7 +5,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from fastapi import FastAPI, Request
|
||||
from fastapi.responses import JSONResponse
|
||||
from fastapi.responses import JSONResponse, RedirectResponse
|
||||
|
||||
from translate_gateway.errors import GatewayError, NoBackendError
|
||||
|
||||
@@ -32,6 +32,10 @@ def create_app(gateway, engines, *, detector=None):
|
||||
return detector
|
||||
return next((e for e in engines.values() if hasattr(e, "detect")), None)
|
||||
|
||||
@app.get("/", include_in_schema=False)
|
||||
async def _root() -> RedirectResponse:
|
||||
return RedirectResponse(url="/docs")
|
||||
|
||||
@app.exception_handler(GatewayError)
|
||||
async def _refuse(_request: Request, exc: GatewayError) -> JSONResponse:
|
||||
"""Answer an error rather than the untranslated source text.
|
||||
|
||||
Reference in new issue
Block a user