Skip to content

Commit d5775c4

Browse files
Yuri ZmytrakovYuri Zmytrakov
authored andcommitted
temp
2 parents f53a968 + 8cd3a5c commit d5775c4

File tree

2 files changed

+51
-17
lines changed

2 files changed

+51
-17
lines changed

Dockerfile

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
FROM python:3.13-slim
2+
3+
RUN apt-get update && apt-get install -y \
4+
build-essential \
5+
&& apt-get clean \
6+
&& rm -rf /var/lib/apt/lists/*
7+
8+
WORKDIR /app
9+
10+
COPY README.md .
11+
COPY stac_fastapi/opensearch/setup.py stac_fastapi/opensearch/
12+
COPY stac_fastapi/core/setup.py stac_fastapi/core/
13+
COPY stac_fastapi/sfeos_helpers/setup.py stac_fastapi/sfeos_helpers/
14+
15+
16+
RUN pip install --no-cache-dir --upgrade pip setuptools wheel
17+
18+
COPY stac_fastapi/ stac_fastapi/
19+
20+
RUN pip install --no-cache-dir ./stac_fastapi/core
21+
RUN pip install --no-cache-dir ./stac_fastapi/sfeos_helpers
22+
RUN pip install --no-cache-dir ./stac_fastapi/opensearch[server]
23+
24+
EXPOSE 8080
25+
26+
CMD ["uvicorn", "stac_fastapi.opensearch.app:app", "--host", "0.0.0.0", "--port", "8080"]

stac_fastapi/core/stac_fastapi/core/core.py

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -672,22 +672,22 @@ async def post_search(
672672
links = await PagingLinks(request=request, next=next_token).get_links()
673673

674674
collection_links = []
675-
if search_request.collections:
676-
for collection_id in search_request.collections:
677-
collection_links.extend(
678-
[
679-
{
680-
"rel": "collection",
681-
"type": "application/json",
682-
"href": urljoin(base_url, f"collections/{collection_id}"),
683-
},
684-
{
685-
"rel": "parent",
686-
"type": "application/json",
687-
"href": urljoin(base_url, f"collections/{collection_id}"),
688-
},
689-
]
690-
)
675+
if items and search_request.collections and len(search_request.collections) == 1:
676+
collection_id = search_request.collections[0]
677+
collection_links.extend(
678+
[
679+
{
680+
"rel": "collection",
681+
"type": "application/json",
682+
"href": urljoin(base_url, f"collections/{collection_id}"),
683+
},
684+
{
685+
"rel": "parent",
686+
"type": "application/json",
687+
"href": urljoin(base_url, f"collections/{collection_id}"),
688+
},
689+
]
690+
)
691691
links.extend(collection_links)
692692

693693
if redis:
@@ -696,12 +696,20 @@ async def post_search(
696696

697697
prev_link = await get_prev_link(redis, token_param)
698698
if prev_link:
699+
method = "GET"
700+
for link in links:
701+
if link.get("rel") == "next" and "method" in link:
702+
method = link["method"]
703+
break
704+
else:
705+
method = request.method
706+
699707
links.insert(
700708
0,
701709
{
702710
"rel": "previous",
703711
"type": "application/json",
704-
"method": "GET",
712+
"method": method,
705713
"href": prev_link,
706714
},
707715
)

0 commit comments

Comments
 (0)