Skip to content

/catalog link is not populated at the root #8

Description

@bkanuka

Truthfully I don't love how stac-fastapi populates the links on the root. It seems to be done in the core logic, rather than extensions being able to add to the list of links on the home page (maybe through the register method). Without modifying stac-fastapi, one way of getting /catalogs added to the root list of links is:

@attr.s
class CatalogsCoreClient(CoreCrudClient):
    """Extends CoreCrudClient to add catalog links to the landing page."""

    async def landing_page(self, **kwargs):
        """Add /catalogs link to the landing page when the catalogs extension is enabled."""
        result = await super().landing_page(**kwargs)
        if self.extension_is_enabled("CatalogsExtension"):
            base_url = get_base_url(kwargs["request"])
            result["links"].append(
                {
                    "rel": "catalogs",
                    "type": "application/json",
                    "title": "Catalogs available for this API",
                    "href": urljoin(base_url, "catalogs"),
                }
            )
        return result

Then use this as the client when initializing StacApi.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions