mirror of
https://github.com/nonebot/nonebot2.git
synced 2025-07-28 08:41:29 +00:00
💡 add depends example
This commit is contained in:
@ -26,3 +26,18 @@ sidebarDepth: 0
|
||||
|
||||
|
||||
* `use_cache: bool = True`: 是否使用缓存。默认为 `True`。
|
||||
|
||||
|
||||
```python
|
||||
def depend_func() -> Any:
|
||||
return ...
|
||||
|
||||
def depend_gen_func():
|
||||
try:
|
||||
yield ...
|
||||
finally:
|
||||
...
|
||||
|
||||
async def handler(param_name: Any = Depends(depend_func), gen: Any = Depends(depend_gen_func)):
|
||||
...
|
||||
```
|
||||
|
Reference in New Issue
Block a user