File tree Expand file tree Collapse file tree 1 file changed +20
-1
lines changed
stac_fastapi/core/stac_fastapi/core Expand file tree Collapse file tree 1 file changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -310,7 +310,18 @@ async def item_collection(
310310 """
311311 request : Request = kwargs ["request" ]
312312 token = request .query_params .get ("token" )
313-
313+ if not hasattr (self , '_prev_links' ):
314+ self ._prev_links = {}
315+
316+ session_id = request .cookies .get ('stac_session' , 'default_session' )
317+ current_self_link = str (request .url )
318+
319+ if session_id not in self ._prev_links :
320+ self ._prev_links [session_id ] = []
321+
322+ history = self ._prev_links [session_id ]
323+ if not history or current_self_link != history [- 1 ]:
324+ history .append (current_self_link )
314325 base_url = str (request .base_url )
315326
316327 collection = await self .get_collection (
@@ -370,6 +381,14 @@ async def item_collection(
370381 ]
371382
372383 paging_links = await PagingLinks (request = request , next = next_token ).get_links ()
384+ history = self ._prev_links .get (session_id , [])
385+ if len (history ) > 1 :
386+ previous_self_link = history [- 2 ]
387+ paging_links .append ({
388+ "rel" : "previous" ,
389+ "type" : "application/json" ,
390+ "href" : previous_self_link ,
391+ })
373392 links = collection_links + paging_links
374393
375394 return stac_types .ItemCollection (
You can’t perform that action at this time.
0 commit comments