21 lines
568 B
Python
21 lines
568 B
Python
from __future__ import annotations
|
|
|
|
import httpx
|
|
from fastapi.responses import JSONResponse
|
|
|
|
|
|
def upstream_error(panel: str) -> JSONResponse:
|
|
return JSONResponse(status_code=502, content={"error": "upstream_failure", "panel": panel})
|
|
|
|
|
|
def async_transport() -> httpx.AsyncBaseTransport | None:
|
|
return None
|
|
|
|
|
|
def client(base_url: str, headers: dict[str, str] | None = None) -> httpx.AsyncClient:
|
|
return httpx.AsyncClient(
|
|
base_url=base_url.rstrip("/"),
|
|
headers=headers or {},
|
|
timeout=20.0,
|
|
transport=async_transport(),
|
|
)
|