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

Set content-type to geojson for search results #288

Merged
merged 5 commits into from
Nov 30, 2021

Conversation

moradology
Copy link
Collaborator

@moradology moradology commented Nov 9, 2021

Related Issue(s): #220

Description:
This PR changes the /search endpoint's headers to reflect the fact that it returns geojson rather than mere json, which is in line with the STAC api spec

PR Checklist:

  • Code is formatted and linted (run pre-commit run --all-files)
  • Tests pass (run make test)
  • Documentation has been updated to reflect changes, if applicable, and docs build successfully (run make docs)
  • Changes are added to the CHANGELOG.

@moradology moradology force-pushed the fix/search-content-type branch from 7815e90 to a1e4038 Compare November 9, 2021 15:35
@@ -175,12 +181,12 @@ def register_post_search(self):
response_model=(ItemCollection if not fields_ext else None)
if self.settings.enable_response_models
else None,
response_class=self.response_class,
response_class=GeoJSONResponse,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will cause the GeoJSONResponse to not use ORJSONResponse if the self.response_class is ORJSONResponse, leading to slowdowns in what's the largest API responses.

Is there a way to just set the media_type at response class creation time instead of setting the media type through this mechanism?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To resolve this, I've used importlib to conditionally use ORJSONResponse when orjson is available and JSONResponse otherwise.

@moradology moradology merged commit c844034 into stac-utils:master Nov 30, 2021
@moradology moradology deleted the fix/search-content-type branch November 30, 2021 16:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants