ApiRegistry
Registry that creates and stores FastAPI sub-apps. Each registered app will be mounted on the main app at the specified path.
Registration methods:
register_api(path, ...)-- creates a FastAPI app at the given mount path. Passwith_exception_handlers=Trueto add the standard exception handlers automatically.register_brick_app(brick_name, ...)-- convenience wrapper that callsregister_apiwith path/brick/{brick_name}/andwith_exception_handlers=Trueby default.configure_exception_handlers(app)-- public helper that adds the three standard exception handlers (HTTPException, RequestValidationError, generic Exception) to any FastAPI app.
Usage from an external brick::
from gws_core import ApiRegistry
eln_app = ApiRegistry.register_brick_api("gws_eln")
@eln_app.get("/my-route")
def my_route():
return {"hello": "world"}
Clear all registered apis. Useful for tests.
Add standard exception handlers to a FastAPI app.
Adds handlers for HTTPException, RequestValidationError, and generic Exception using the standard ExceptionHandler.
FastAPIReturn all registered apis.
dictGet the mount path for a registered brick API.
strstrCreate and register a FastAPI sub-app at the given mount path.
strstr | Nonebool - TrueFastAPICreate and register a FastAPI sub-app for an external brick.
The app is mounted at /brick/{brick_name}/ and has the standard
exception handlers automatically configured by default.
strstr | None - /docsbool - TrueFastAPI