GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — FastAPI Integration FastAPI Integration
Asterios Raptis edited this page
PluginForge can mount plugin routes onto a FastAPI application. FastAPI is an optional dependency: install it separately when you need this integration. pip install pluginforge fastapi Note: the from fastapi import FastAPI from pluginforge import PluginManager app = FastAPI() pm = PluginManager("config/app.yaml") pm.discover_plugins() pm.mount_routes(app) The default prefix is pm.mount_routes(app, prefix="/v2/api")
This fix closes a recursion-cascade Bibliogon reported (RecursionError in Plugins provide routes by overriding from fastapi import APIRouter from pluginforge import BasePlugin class HelloPlugin(BasePlugin): name = "hello" def get_routes(self) -> list: router = APIRouter(prefix="/hello") @router.get("/greet") def greet(): greeting = self.config.get("greeting", "Hello") return {"message": greeting} @router.get("/info") def info(): return {"plugin": self.name, "version": self.version} return [router] With default prefix, routes are available at: Plugins control their own URL structure. An export plugin can define routes like
# Recommended: one parent router with nested sub-routers. panels_router = APIRouter(prefix="/panels") panels_router.add_api_route("/", list_panels, methods=["GET"]) bubbles_router = APIRouter(prefix="/bubbles") bubbles_router.add_api_route("/", list_bubbles, methods=["GET"]) class ComicsPlugin(BasePlugin): name = "comics" def get_routes(self) -> list: parent = APIRouter(prefix="/comics") parent.include_router(panels_router) parent.include_router(bubbles_router) return [parent] Plugins returning more than one top-level router from You can expose a health endpoint using @app.get("/api/health") def health(): return pm.health_check() Response: {
"export": {"status": "ok", "formats": ["epub", "pdf"]},
"grammar": {"status": "error", "error": "LanguageTool API unreachable"}
}
Clone this wiki locally |
| You are visitor 01402520 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |