Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions stac_fastapi/api/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from starlette.status import HTTP_204_NO_CONTENT

from stac_fastapi.api.models import APIRequest
from stac_fastapi.types.links import hydrate_inferred_links


def _wrap_response(resp: Any, response_class: Type[Response]) -> Response:
Expand Down Expand Up @@ -53,9 +54,9 @@ async def _endpoint(
request_data: request_model = Depends(), # type:ignore
):
"""Endpoint."""
return _wrap_response(
await func(request=request, **request_data.kwargs()), response_class
)
response = await func(**request_data.kwargs())
response = hydrate_inferred_links(request, response)
return _wrap_response(response, response_class)

elif issubclass(request_model, BaseModel):

Expand All @@ -64,9 +65,9 @@ async def _endpoint(
request_data: request_model, # type:ignore
):
"""Endpoint."""
return _wrap_response(
await func(request_data, request=request), response_class
)
response = await func(request_data)
response = hydrate_inferred_links(request, response)
return _wrap_response(response, response_class)

else:

Expand All @@ -75,9 +76,9 @@ async def _endpoint(
request_data: Dict[str, Any], # type:ignore
):
"""Endpoint."""
return _wrap_response(
await func(request_data, request=request), response_class
)
response = await func(request_data)
response = hydrate_inferred_links(request, response)
return _wrap_response(response, response_class)

return _endpoint

Expand Down
Loading