-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
issue-1Issue 1Issue 1
Description
Background
in https://github.com/developmentseed/eoapi-devseed we've added custom HTML rendering for the STAC API. This meant re-writing most of the Client https://github.com/developmentseed/eoapi-devseed/blob/main/runtimes/eoapi/stac/eoapi/stac/client.py to:
- advertise both
f=htmloracceptheaders - advertise HTML response type
It worked well but this is super custom and some users have expressed the need of the same feature for their own stac-fastapi instance.
In this repo, we will explore the creation of a starlette Middleware which could be added to any stac-fastapi application. The idea is to intercept the response and then check if f=html or Accept: text/html was provided in the request. If yes, then we encode the response into an HTML document.
Pros:
- No need to customize your client
- should work for any stac-fastapi application
- lightweight
Cons:
No OpenAPI advertising (for now)
from starlette.middleware import Middleware
from stac_fastapi.api.app import StacApi
from stac_fastapi.html.middleware import HTMLRenderMiddleware
api = StacApi(
middlewares=[
Middleware(HTMLRenderMiddleware),
],
)hrodmn
Metadata
Metadata
Assignees
Labels
issue-1Issue 1Issue 1