-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
🌐 Add Chinese translation for Tutorial - Middleware #2334
🌐 Add Chinese translation for Tutorial - Middleware #2334
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2334 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 242 242
Lines 7396 7396
=========================================
Hits 7396 7396 Continue to review full report at Codecov.
|
@tiangolo I don't know why occured this error when build doc . |
Hey @lpdswing ! Thanks for letting me know. The error had nothing to do with you, it was caused by a recent change I made when I enabled the new features of Material for MkDocs Insiders, but I incorrectly handled the install in PRs from forks. I just fixed it and updated your branch, so it's now passing and ready for review 🎉 |
📝 Docs preview for commit 323c67e at: https://5faaf0395dbd2f556b35a13a--fastapi.netlify.app |
OK,thx发自我的华为手机-------- 原始邮件 --------发件人: Sebastián Ramírez <[email protected]>日期: 2020年11月11日周三 凌晨3:56收件人: tiangolo/fastapi <[email protected]>抄送: lpdswing <[email protected]>, Mention <[email protected]>主 题: Re: [tiangolo/fastapi] Add chinese translate for tutorial-middleware (#2334)
Hey @lpdswing ! Thanks for letting me know.
The error had nothing to do with you, it was caused by a recent change I made when I enabled the new features of Material for MkDocs Insiders, but I incorrectly handled the install in PRs from forks.
I just fixed it and updated your branch, so it's now passing and ready for review 🎉
—You are receiving this because you were mentioned.Reply to this email directly, view it on GitHub, or unsubscribe.
|
docs/zh/docs/tutorial/middleware.md
Outdated
|
||
* 它接收你的应用程序的每一个**request**. | ||
* 然后它可以对这个**request**做一些事情或者执行任何需要的代码. | ||
* 然后它将**request**传递给应用程序的其他部分 (通过某种*路径操作*). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
然后它将请求传递给应用程序的其他部分(某个路径操作)进行处理。
docs/zh/docs/tutorial/middleware.md
Outdated
* 然后它返回这个 **response**. | ||
|
||
!!! note "技术细节" | ||
如果你依赖了 `yield`, 退出代码将在执行中间件*后*执行. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
如果你有使用了 yield
关键字的依赖,依赖中的退出代码将在执行中间件之后执行。
📝 Docs preview for commit 5cc7e56 at: https://5faccda1187ac845973be867--fastapi.netlify.app |
docs/zh/docs/tutorial/middleware.md
Outdated
|
||
要创建中间件你可以在函数的顶部使用装饰器 `@app.middleware("http")`. | ||
|
||
中间件参数接收: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
中间件函数接收如下参数:
docs/zh/docs/tutorial/middleware.md
Outdated
* 然后它返回这个 **响应**. | ||
|
||
!!! note "技术细节" | ||
如果你使用了 `yield`关键字依赖, 依赖中的退出代码将在执行中间件*后*执行. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Leave a space after yield
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
删除空格?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
应该是 yhield
前后都要有空格。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yield
后面加个空格
docs/zh/docs/tutorial/middleware.md
Outdated
|
||
* `request`. | ||
* 一个函数 `call_next` 它将接收 `request` 作为参数. | ||
* 这个函数将 `request` 传递个相应的 *路径操作*. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
传递给
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thx
docs/zh/docs/tutorial/middleware.md
Outdated
!!! note "技术细节" | ||
你也可以使用 `from starlette.requests import Request`. | ||
|
||
**FastAPI** 为了开发者方便提供了该对象. 但其实它直接来自于Starlette. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Leave a space before Starlette
.
!!! tip | ||
请记住可以 <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers" class="external-link" target="_blank">用'X-' 前缀</a>添加专有自定义请求头. | ||
|
||
但是如果你想让浏览器中的客户端看到你的自定义请求头, 你需要把它们加到 CORS 配置 ([CORS (Cross-Origin Resource Sharing)](cors.md){.internal-link target=_blank}) 的 `expose_headers` 参数中,在 <a href="https://www.starlette.io/middleware/#corsmiddleware" class="external-link" target="_blank">Starlette's CORS docs</a>文档中. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Leave spaces for Starlette's CORS docs
.
|
||
### 在 `response` 的前和后 | ||
|
||
在任何*路径操作*收到`request`前,可以添加要和请求一起运行的代码. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wrap enlish words with a space.
…g_zh/tutorial-middleware
📝 Docs preview for commit acdf714 at: https://5fbdba4452dc482fa61cf1fc--fastapi.netlify.app |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should also translate all the punctuation marks.
docs/zh/docs/tutorial/middleware.md
Outdated
|
||
要创建中间件你可以在函数的顶部使用装饰器 `@app.middleware("http")`. | ||
|
||
中间件参数接收: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
中间件函数接受:
docs/zh/docs/tutorial/middleware.md
Outdated
* 然后它返回这个 **响应**. | ||
|
||
!!! note "技术细节" | ||
如果你使用了 `yield`关键字依赖, 依赖中的退出代码将在执行中间件*后*执行. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
应该是 yhield
前后都要有空格。
Awesome! Thank you @lpdswing for your contribution! 🍰 🚀 And thanks @waynerv, @RunningIkkyu, and @maoyibo for the reviews 🙇 ☕ I'm going to wait for the punctuation fixes and then the approval by @waynerv before merging 🤓 📝 |
…wing/fastapi; branch 'master' of https://github.com/tiangolo/fastapi into lang_zh/tutorial-middleware
📝 Docs preview for commit b4820dd at: https://5fc4a2afb9a514801bc630d2--fastapi.netlify.app |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tiangolo I think this PR is ready for merging.
Excellent, thanks for the confirmation @waynerv ! 🚀 |
No description provided.