stac-fastapi
stac-fastapi copied to clipboard
Need a new way to declare behaviour and modification of API from extensions
While writing code to add the filters extension it became clear that it was difficult for downstream applications to dynamically register the extensions they implement and for this to modify the response without also needing to update the implementation.
There are 3 things that extensions do in the call/response flow:
- Add an additional, stand-alone endpoint
- Modify the response from an existing endpoint
- Modify the queryset behind the response on an existing endpoint
The current framework works well with additional, stand-alone modifications. The other two rely on adding:
if self.extension_is_enabled(<ExtensionClass>):
# Do something
constructs from within the "Core" client.
It would be nice if extensions define the logic and perhaps some base implementation or abstract implementation for the additions and modifications to the basic STAC API implementation.
Of course, depending on the extension, some implementation-specific code would need to be written to define the interaction between the extension and the database but it would be good to be able to keep this out of the core.
I will continue to have a think about how this might be accomplished and will make a PR if I come up with anything, but as this will be significant work, it would be good to get some feedback. Or if someone else wants to make a start... 😉
Would also impact #175