Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 1 #1

Open
vincentsarago opened this issue Mar 24, 2025 · 0 comments
Open

Issue 1 #1

vincentsarago opened this issue Mar 24, 2025 · 0 comments
Labels
issue-1 Issue 1

Comments

@vincentsarago
Copy link
Member

vincentsarago commented Mar 24, 2025

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=html or accept headers
  • 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),
    ],
)
@vincentsarago vincentsarago added the issue-1 Issue 1 label Mar 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
issue-1 Issue 1
Projects
None yet
Development

No branches or pull requests

1 participant