-
Notifications
You must be signed in to change notification settings - Fork 31
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
add paging links tests #195
base: main
Are you sure you want to change the base?
Conversation
@vincentsarago thanks for looking into this, it could very well be an interaction with this is roughly how my current setup looks prefix = "/stac"
_app = FastAPI(
root_path=prefix,
lifespan=lifespan,
)
# ... more setup
_api = StacApi(
title=title,
description=description,
settings=settings,
extensions=application_extensions,
client=CoreCrudClient(pgstac_search_model=post_request_model),
items_get_request_model=items_get_request_model,
search_get_request_model=get_request_model,
search_post_request_model=post_request_model,
collections_get_request_model=collections_get_request_model,
middlewares=middlewares,
app=_app,
**kw,
)
# AWS Lambda wrapper
handler = Mangum(
app,
api_gateway_base_path=app.root_path,
lifespan="off",
text_mime_types=text_mime_types,
) In the debugger I see that |
I wonder if this is because we don't set 🤔 |
@vincentsarago I'm not too familiar with FastAPI or web programming in Python in general, but my understanding is this
So I think in the test you should NOT set |
The test added in this PR test endpoint with/without root-path or prefix (2x2 matrix) if we look at https://github.com/encode/starlette/blob/a7d0b14c7378aa2e95b0b13583fe0dadace363be/tests/test_routing.py#L568-L575, it seems that we have to call |
@vincentsarago see #201 With that change to the test, I DO get test failure for link generation on my fork:
|
endpoint_prefix = root_path + prefix | ||
url_prefix = "http://stac.io" + endpoint_prefix |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see #201 , but this should also work:
endpoint_prefix = root_path + prefix | |
url_prefix = "http://stac.io" + endpoint_prefix | |
endpoint_prefix = prefix | |
url_prefix = "http://stac.io" + root_path + endpoint_prefix |
we want to model situation when root_path
is dropped by the reverse proxy, but needs to be present in the output links as this is the only way to reach the API.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤔 I'm not sure to get this to be honest
In all cases, the client should be called {root-path}/{prefix}/endpoint
as shown in https://github.com/encode/starlette/blob/a7d0b14c7378aa2e95b0b13583fe0dadace363be/tests/test_routing.py#L573-L575
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤔 I'm not sure to get this to be honest
In all cases, the client should be called
{root-path}/{prefix}/endpoint
as shown in https://github.com/encode/starlette/blob/a7d0b14c7378aa2e95b0b13583fe0dadace363be/tests/test_routing.py#L573-L575
I don't understand how you come to this conclusion from that one test alone. I'm just trying to replicate the scenario I see in the debugger of a real system. Omitting the root path in the call to the test client still routes to the endpoint in question, but this time with the request object behaving the same way as in the real system behind a reverse proxy that removes routing prefix.
trying to replicate issue from #194
cc @Kirill888