Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Comments

🌐 Add Chinese translation for Tutorial - Middleware#2334

Merged
tiangolo merged 8 commits intofastapi:masterfrom
lpdswing:lang_zh/tutorial-middleware
Mar 27, 2021
Merged

🌐 Add Chinese translation for Tutorial - Middleware#2334
tiangolo merged 8 commits intofastapi:masterfrom
lpdswing:lang_zh/tutorial-middleware

Conversation

@lpdswing
Copy link
Contributor

No description provided.

@codecov
Copy link

codecovbot commentedNov 10, 2020
edited
Loading

Codecov Report

Merging#2334 (b4820dd) intomaster (51e920e) willnot change coverage.
The diff coverage isn/a.

Impacted file tree graph

@@            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.

Legend -Click here to learn more
Δ = absolute <relative> (impact),ø = not affected,? = missing data
Powered byCodecov. Last update51e920e...b4820dd. Read thecomment docs.

@lpdswing
Copy link
ContributorAuthor

@tiangolo I don't know why occured this error when build doc .
image

@tiangolo
Copy link
Member

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 ofMaterial 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 🎉

@tiangolotiangolo added awaiting-review lang-allTranslations lang-zhChinese translations labelsNov 10, 2020
@github-actions
Copy link
Contributor

📝 Docs preview for commit323c67e at:https://5faaf0395dbd2f556b35a13a--fastapi.netlify.app

@lpdswing
Copy link
ContributorAuthor

lpdswing commentedNov 11, 2020 via email

OK,thx发自我的华为手机-------- 原始邮件 --------发件人: Sebastián Ramírez <notifications@github.com>日期: 2020年11月11日周三 凌晨3:56收件人: tiangolo/fastapi <fastapi@noreply.github.com>抄送: lpdswing <lpdswing@qq.com>, Mention <mention@noreply.github.com>主 题: 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.

@lpdswinglpdswing mentioned this pull requestNov 11, 2020

* 它接收你的应用程序的每一个**request**.
* 然后它可以对这个**request**做一些事情或者执行任何需要的代码.
* 然后它将**request**传递给应用程序的其他部分 (通过某种*路径操作*).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

然后它将请求传递给应用程序的其他部分(某个路径操作)进行处理。

* 然后它返回这个 **response**.

!!! note "技术细节"
如果你依赖了 `yield`, 退出代码将在执行中间件*后*执行.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

如果你有使用了yield 关键字的依赖,依赖中的退出代码将在执行中间件之后执行。

@github-actions
Copy link
Contributor

📝 Docs preview for commit5cc7e56 at:https://5faccda1187ac845973be867--fastapi.netlify.app


要创建中间件你可以在函数的顶部使用装饰器 `@app.middleware("http")`.

中间件参数接收:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

中间件函数接收如下参数:

* 然后它返回这个 **响应**.

!!! note "技术细节"
如果你使用了 `yield`关键字依赖, 依赖中的退出代码将在执行中间件*后*执行.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Leave a space afteryield.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

删除空格?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

应该是yhield 前后都要有空格。

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

yield 后面加个空格


* `request`.
* 一个函数 `call_next` 它将接收 `request` 作为参数.
* 这个函数将 `request` 传递个相应的 *路径操作*.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

传递给

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

thx

!!! note "技术细节"
你也可以使用 `from starlette.requests import Request`.

**FastAPI** 为了开发者方便提供了该对象. 但其实它直接来自于Starlette.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Leave a space beforeStarlette.

!!! 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>文档中.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Leave spaces forStarlette's CORS docs.


### 在 `response` 的前和后

在任何*路径操作*收到`request`前,可以添加要和请求一起运行的代码.
Copy link
Contributor

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.

@github-actions
Copy link
Contributor

📝 Docs preview for commitacdf714 at:https://5fbdba4452dc482fa61cf1fc--fastapi.netlify.app

Copy link
Contributor

@waynervwaynerv left a 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.

blt232018 reacted with thumbs up emoji

要创建中间件你可以在函数的顶部使用装饰器 `@app.middleware("http")`.

中间件参数接收:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

中间件函数接受:

* 然后它返回这个 **响应**.

!!! note "技术细节"
如果你使用了 `yield`关键字依赖, 依赖中的退出代码将在执行中间件*后*执行.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

应该是yhield 前后都要有空格。

@tiangolotiangolo changed the titleAdd chinese translate for tutorial-middleware🌐 Add Chinese translation for Tutorial - MiddlewareNov 25, 2020
@tiangolo
Copy link
Member

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 🤓 📝

@github-actions
Copy link
Contributor

📝 Docs preview for commitb4820dd at:https://5fc4a2afb9a514801bc630d2--fastapi.netlify.app

Copy link
Contributor

@waynervwaynerv left a 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.

tiangolo reacted with rocket emoji
@tiangolo
Copy link
Member

Excellent, thanks for the confirmation@waynerv ! 🚀

@tiangolotiangolo merged commit368d314 intofastapi:masterMar 27, 2021
0xMario27 added a commit to 0xMario27/fastapi that referenced this pull requestApr 25, 2021
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

3 more reviewers

@maoyibomaoyibomaoyibo approved these changes

@RunningIkkyuRunningIkkyuRunningIkkyu approved these changes

@waynervwaynervwaynerv approved these changes

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Labels

approved-2lang-allTranslationslang-zhChinese translations

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

5 participants

@lpdswing@tiangolo@maoyibo@RunningIkkyu@waynerv

[8]ページ先頭

©2009-2026 Movatter.jp