diff --git a/docs/settings.md b/docs/settings.md index 9360622..8b12750 100644 --- a/docs/settings.md +++ b/docs/settings.md @@ -62,3 +62,4 @@ In version `6.0.0` we've renamed the PG configuration variable to match the offi - `CORS_METHODS`: A list of HTTP methods that should be allowed for cross-origin requests. Defaults to `"GET,POST,OPTIONS"` - `USE_API_HYDRATE`: perform hydration of stac items within stac-fastapi - `INVALID_ID_CHARS`: list of characters that are not allowed in item or collection ids (used in Transaction endpoints) +- `PREFIX_PATH`: An optional path prefix for the underlying FastAPI router. diff --git a/stac_fastapi/pgstac/app.py b/stac_fastapi/pgstac/app.py index 5d42f76..cd83277 100644 --- a/stac_fastapi/pgstac/app.py +++ b/stac_fastapi/pgstac/app.py @@ -9,7 +9,7 @@ from contextlib import asynccontextmanager from brotli_asgi import BrotliMiddleware -from fastapi import FastAPI +from fastapi import APIRouter, FastAPI from stac_fastapi.api.app import StacApi from stac_fastapi.api.middleware import CORSMiddleware, ProxyHeaderMiddleware from stac_fastapi.api.models import ( @@ -171,6 +171,7 @@ async def lifespan(app: FastAPI): description=settings.stac_fastapi_description, lifespan=lifespan, ), + router=APIRouter(prefix=settings.prefix_path), settings=settings, extensions=application_extensions, client=CoreCrudClient(pgstac_search_model=post_request_model), diff --git a/stac_fastapi/pgstac/config.py b/stac_fastapi/pgstac/config.py index c874181..15690fa 100644 --- a/stac_fastapi/pgstac/config.py +++ b/stac_fastapi/pgstac/config.py @@ -159,11 +159,13 @@ class Settings(ApiSettings): """API settings. Attributes: + prefix_path: An optional path prefix for the underyling FastAPI router. use_api_hydrate: perform hydration of stac items within stac-fastapi. invalid_id_chars: list of characters that are not allowed in item or collection ids. """ + prefix_path: str = "" use_api_hydrate: bool = False invalid_id_chars: List[str] = DEFAULT_INVALID_ID_CHARS base_item_cache: Type[BaseItemCache] = DefaultBaseItemCache