@@ -672,22 +672,22 @@ async def post_search(
672
672
links = await PagingLinks (request = request , next = next_token ).get_links ()
673
673
674
674
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 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
+ )
691
691
links .extend (collection_links )
692
692
693
693
if redis :
@@ -696,12 +696,20 @@ async def post_search(
696
696
697
697
prev_link = await get_prev_link (redis , token_param )
698
698
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
+
699
707
links .insert (
700
708
0 ,
701
709
{
702
710
"rel" : "previous" ,
703
711
"type" : "application/json" ,
704
- "method" : "GET" ,
712
+ "method" : method ,
705
713
"href" : prev_link ,
706
714
},
707
715
)
0 commit comments