File tree Expand file tree Collapse file tree 1 file changed +12
-10
lines changed
Expand file tree Collapse file tree1 file changed +12
-10
lines changed Original file line number Diff line number Diff line change 11# Cookie 参数
22
3- 你可以像定义 ` Query ` 参数和 ` Path ` 参数一样来定义 ` Cookie ` 参数 。
3+ 定义 ` Cookie ` 参数与定义 ` Query ` 和 ` Path ` 参数一样 。
44
55## 导入 ` Cookie `
66
7- 首先,导入 ` Cookie ` :
7+ 首先,导入 ` Cookie ` :
88
99=== "Python 3.10+"
1010
4444
4545## 声明 ` Cookie ` 参数
4646
47- 声明 ` Cookie ` 参数的结构与声明 ` Query ` 参数和 ` Path ` 参数时相同 。
47+ 声明 ` Cookie ` 参数的方式与声明 ` Query ` 和 ` Path ` 参数相同 。
4848
49- 第一个值是参数的默认值,同时也可以传递所有验证参数或注释参数,来校验参数 :
49+ 第一个值是默认值,还可以传递所有验证参数或注释参数 :
5050
5151
5252=== "Python 3.10+"
8686 ```
8787
8888!!! note "技术细节"
89- ` Cookie ` 、` Path ` 、` Query ` 是兄弟类,它们都继承自公共的 ` Param ` 类
9089
91- 但请记住,当你从 `fastapi` 导入的 `Query` 、`Path`、`Cookie` 或其他参数声明函数,这些实际上是返回特殊类的函数 。
90+ `Cookie` 、`Path` 、`Query` 是**兄弟类**,都继承自共用的 `Param` 类 。
9291
93- !!! info
94- 你需要使用 ` Cookie ` 来声明 cookie 参数,否则参数将会被解释为查询参数。
92+ 注意,从 `fastapi` 导入的 `Query`、`Path`、`Cookie` 等对象,实际上是返回特殊类的函数。
9593
96- ## 总结
94+ !!! info "说明"
9795
98- 使用 ` Cookie ` 声明 cookie 参数,使用方式与 ` Query ` 和 ` Path ` 类似。
96+ 必须使用 `Cookie` 声明 cookie 参数,否则该参数会被解释为查询参数。
97+
98+ ## 小结
99+
100+ 使用 ` Cookie ` 声明 cookie 参数的方式与 ` Query ` 和 ` Path ` 相同。
You can’t perform that action at this time.
0 commit comments