Locate an existing parameter in the decorated endpoint If not found, returns the injectable parameter, and adds it to the to_inject list.
(
sig: Signature, dep: Parameter, to_inject: List[Parameter]
)
| 50 | |
| 51 | |
| 52 | def _locate_param( |
| 53 | sig: Signature, dep: Parameter, to_inject: List[Parameter] |
| 54 | ) -> Parameter: |
| 55 | """Locate an existing parameter in the decorated endpoint |
| 56 | |
| 57 | If not found, returns the injectable parameter, and adds it to the to_inject list. |
| 58 | |
| 59 | """ |
| 60 | param = next( |
| 61 | (p for p in sig.parameters.values() if p.annotation is dep.annotation), None |
| 62 | ) |
| 63 | if param is None: |
| 64 | to_inject.append(dep) |
| 65 | param = dep |
| 66 | return param |
| 67 | |
| 68 | |
| 69 | def _uncacheable(request: Optional[Request]) -> bool: |