feat: integrate DSH Filebrowser (pinned v2.32.0, dark mode, toggle selector UI from Claude Design, /u/nabil/files/ proxy)
This commit is contained in:
+22
-1
@@ -1,9 +1,30 @@
|
||||
from fastapi import APIRouter, Request, HTTPException
|
||||
from app.config import UNIVERSES
|
||||
from app.config import UNIVERSES, get_universe
|
||||
from app.proxy import proxy_request
|
||||
|
||||
router = APIRouter(prefix="/u", tags=["Universe Proxy"])
|
||||
|
||||
@router.api_route("/{universe_id}/files", methods=["GET", "POST", "PUT", "DELETE", "PATCH", "HEAD", "OPTIONS"])
|
||||
@router.api_route("/{universe_id}/files/", methods=["GET", "POST", "PUT", "DELETE", "PATCH", "HEAD", "OPTIONS"])
|
||||
@router.api_route("/{universe_id}/files/{path:path}", methods=["GET", "POST", "PUT", "DELETE", "PATCH", "HEAD", "OPTIONS"])
|
||||
async def dynamic_files_proxy(universe_id: str, request: Request, path: str = ""):
|
||||
if universe_id not in UNIVERSES:
|
||||
raise HTTPException(status_code=404, detail=f"Universe '{universe_id}' not found.")
|
||||
|
||||
universe = UNIVERSES[universe_id]
|
||||
if not universe.supports_files or not universe.files_url:
|
||||
raise HTTPException(status_code=404, detail=f"Universe '{universe_id}' does not have an active filebrowser.")
|
||||
|
||||
# Filebrowser runs with --baseurl /u/{universe_id}/files
|
||||
full_subpath = f"u/{universe_id}/files/{path}".rstrip("/") if path else f"u/{universe_id}/files/"
|
||||
|
||||
return await proxy_request(
|
||||
request=request,
|
||||
backend_url=universe.files_url,
|
||||
path=full_subpath,
|
||||
universe_id=universe_id
|
||||
)
|
||||
|
||||
@router.api_route("/{universe_id}", methods=["GET", "POST", "PUT", "DELETE", "PATCH", "HEAD", "OPTIONS"])
|
||||
@router.api_route("/{universe_id}/", methods=["GET", "POST", "PUT", "DELETE", "PATCH", "HEAD", "OPTIONS"])
|
||||
@router.api_route("/{universe_id}/{path:path}", methods=["GET", "POST", "PUT", "DELETE", "PATCH", "HEAD", "OPTIONS"])
|
||||
|
||||
Reference in New Issue
Block a user