Skip to content

Commit

Permalink
Moving request to kwargs for patch item and collection.
Browse files Browse the repository at this point in the history
  • Loading branch information
rhysrevans3 committed Aug 23, 2024
1 parent b7bcbd5 commit cfc31c6
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions stac_fastapi/types/stac_fastapi/types/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ def patch_item(
collection_id: str,
item_id: str,
patch: Union[Dict, List[PatchOperation]],
request: Request,
**kwargs,
) -> Optional[Union[stac.Item, Response]]:
"""Update an item from a collection.
Expand All @@ -102,7 +101,7 @@ def patch_item(
Returns:
The patched item.
"""
content_type = request.headers.get("content-type", "application/json")
content_type = kwargs["request"].headers.get("content-type", "application/json")
if isinstance(patch, list) and content_type == "application/json-patch+json":
return self.json_patch_item(
collection_id,
Expand Down Expand Up @@ -226,7 +225,6 @@ def patch_collection(
self,
collection_id: str,
patch: Union[Dict, List[PatchOperation]],
request: Request,
**kwargs,
) -> Optional[Union[stac.Collection, Response]]:
"""Update a collection.
Expand All @@ -240,7 +238,7 @@ def patch_collection(
Returns:
The patched collection.
"""
content_type = request.headers.get("content-type", "application/json")
content_type = kwargs["request"].headers.get("content-type", "application/json")
if isinstance(patch, list) and content_type == "application/json-patch+json":
return self.json_patch_collection(collection_id, patch, **kwargs)

Expand Down Expand Up @@ -358,7 +356,6 @@ async def patch_item(
collection_id: str,
item_id: str,
patch: Union[Dict, List[PatchOperation]],
request: Request,
**kwargs,
) -> Optional[Union[stac.Item, Response]]:
"""Update an item from a collection.
Expand All @@ -374,7 +371,7 @@ async def patch_item(
The patched item.
"""
print(type(patch))
content_type = request.headers.get("content-type", "application/json")
content_type = kwargs["request"].headers.get("content-type", "application/json")
if isinstance(patch, list) and content_type == "application/json-patch+json":
return await self.json_patch_item(
collection_id,
Expand Down Expand Up @@ -498,7 +495,6 @@ async def patch_collection(
self,
collection_id: str,
patch: Union[Dict, List[PatchOperation]],
request: Request,
**kwargs,
) -> Optional[Union[stac.Collection, Response]]:
"""Update a collection.
Expand All @@ -512,7 +508,7 @@ async def patch_collection(
Returns:
The patched collection.
"""
content_type = request.headers.get("content-type", "application/json")
content_type = kwargs["request"].headers.get("content-type", "application/json")
if isinstance(patch, list) and content_type == "application/json-patch+json":
return await self.json_patch_collection(collection_id, patch, **kwargs)

Expand Down

0 comments on commit cfc31c6

Please sign in to comment.