File tree Expand file tree Collapse file tree 1 file changed +28
-1
lines changed
stac_fastapi/core/stac_fastapi/core Expand file tree Collapse file tree 1 file changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -255,7 +255,34 @@ async def all_collections(
255255 request = kwargs ["request" ]
256256 base_url = str (request .base_url )
257257
258- limit = int (request .query_params .get ("limit" , os .getenv ("STAC_ITEM_LIMIT" , 10 )))
258+ # Get the global limit from environment variable
259+ global_limit = None
260+ env_limit = os .getenv ("STAC_ITEM_LIMIT" )
261+ if env_limit :
262+ try :
263+ global_limit = int (env_limit )
264+ except ValueError :
265+ # Handle invalid integer in environment variable
266+ pass
267+
268+ # Apply global limit if it exists
269+ if global_limit is not None :
270+ # If a limit was provided, use the smaller of the two
271+ if limit is not None :
272+ limit = min (limit , global_limit )
273+ else :
274+ limit = global_limit
275+ else :
276+ # No global limit, use provided limit or default
277+ if limit is None :
278+ query_limit = request .query_params .get ("limit" )
279+ if query_limit :
280+ try :
281+ limit = int (query_limit )
282+ except ValueError :
283+ limit = 10
284+ else :
285+ limit = 10
259286
260287 token = request .query_params .get ("token" )
261288
You can’t perform that action at this time.
0 commit comments