-
Notifications
You must be signed in to change notification settings - Fork 102
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
Inconsistent path behaviour with APIRouter prefix #427
Comments
I agree with this. I believe forwarding header support is in a good place now with #415 being merged and root_path is supported by both fastapi/uvicorn/gunicorn (https://fastapi.tiangolo.com/advanced/behind-a-proxy/#providing-the-root_path). #429 has a working solution for the APIRouter prefixing issue by propagating the router prefix used by the core endpoints to the rest of the application but I don't think it addresses the main issue here which is that API routers are not used or exposed in a consistent manner throughout the project. For example:
Organizing routers around conformance classes is the most logical approach; all the core endpoints will use one router while all the transactions endpoints will use another etc. But this needs to be implemented consistently throughout the project for it to mean anything. |
I don't get your comment @geospatial-jeff.
UPD: Ahh I see you mean that for those places the router cannot be overridden by a user. |
Yup exactly! If the user can pass their own APIRouter wherever it is appropriate prefixing the entire app (or just a part of it) becomes very simple. |
The pgstac application behaves inconsistently when building response href paths if an APIRouter prefix is provided.
This repo demonstrates the problem behaviour.
The
StacApi
constructor supports a FastAPIAPIRouter
object argument.APIRouter
supports aprefix
string argument. For example:The OpenAPI docs correctly include
/router_prefix
in all paths, but most stac-fastapi responses do not include the prefix inhref
paths. However, a/search
response does include/router_prefix
in thenext
andprev
href
paths if multiple search pages are available. See the referenced repo for steps to observe this behaviour.The links provided by STAC API implementations are extremely valuable and place STAC APIs at Level 3 on the Richardson REST Maturity Model, however this only provides value if the paths can be trusted. I think the pgstac application, and presumably also the sqlalchemy application, would benefit from a holistic review of path handling as there are several issues identifying different problems in path logic:
The text was updated successfully, but these errors were encountered: