@@ -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 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