Skip to content

Issue 1 #1

@vincentsarago

Description

@vincentsarago

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),
    ],
)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions