Skip to content

Commit b9fc206

Browse files
committed
update check_query_params function
1 parent 997dd06 commit b9fc206

File tree

1 file changed

+26
-6
lines changed

1 file changed

+26
-6
lines changed

src/titiler/core/titiler/core/utils.py

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -197,17 +197,37 @@ def extract_query_params(
197197

198198

199199
def check_query_params(
200-
dependencies: List[Callable],
201-
params: Union[QueryParams, Dict],
200+
dependencies: List[Callable], params: Union[QueryParams, Dict]
202201
) -> bool:
203-
"""Check QueryParams for a list of Dependencies."""
202+
"""Check QueryParams for Query dependency.
203+
204+
1. `get_dependant` is used to get the query-parameters required by the `callable`
205+
2. we use `request_params_to_args` to construct arguments needed to call the `callable`
206+
3. we call the `callable` and catch any errors
207+
208+
Important: We assume the `callable` in not a co-routine
209+
210+
"""
211+
qp = (
212+
QueryParams(urlencode(params, doseq=True))
213+
if isinstance(params, Dict)
214+
else params
215+
)
216+
204217
for dependency in dependencies:
205218
try:
206-
_, errors = deserialize_query_params(dependency, params)
207-
if errors:
208-
return False
219+
dep = get_dependant(path="", call=dependency)
220+
if dep.query_params:
221+
# call the dependency with the query-parameters values
222+
query_values, errors = request_params_to_args(dep.query_params, qp)
223+
if errors:
224+
return False
225+
226+
_ = dependency(**query_values)
227+
209228
except Exception:
210229
return False
230+
211231
return True
212232

213233

0 commit comments

Comments
 (0)