-
-
Notifications
You must be signed in to change notification settings - Fork 6.1k
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 Russian translation for docs/ru/docs/tutorial/middleware.md
#10538
Conversation
📝 Docs preview for commit a3d640c at: https://14559915.fastapitiangolo.pages.dev |
|
||
* Он принимает каждый **запрос**, поступающий в ваше приложение. | ||
* Затем он может что-то сделать с этим **запросом** или выполнить любой необходимый код. | ||
* Затем он передает **запрос** на обработку в *операцию пути*. |
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.
...в оставшуюся часть приложения (через операцию пути)
|
||
В приложения **FastAPI** можно добавлять мидлвары. | ||
|
||
Мидлвар - это функция, которая работает с каждым **запросом** до того, как он будет обработан какой-либо *операцией пути*. А также с каждым **ответом** перед его возвратом клиенту. |
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.
...перед отправкой его клиенту.
@@ -0,0 +1,61 @@ | |||
# Мидлвар |
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.
Так себе транслитерация. Есть русские "промежуточное ПО" либо "промежуточный слой кода". Как вариант – переводить по-русски, а в скобках писать (middleware).
* Он принимает каждый **запрос**, поступающий в ваше приложение. | ||
* Затем он может что-то сделать с этим **запросом** или выполнить любой необходимый код. | ||
* Затем он передает **запрос** на обработку в *операцию пути*. | ||
* Затем принимается **ответ**, сгенерированный *операцией пути*. |
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.
Затем он принимает ответ созданный приложением (какой-либо операцией пути)
* Он может что-то сделать с этим **ответом** или выполнить любой необходимый код. | ||
* Затем он возвращает **ответ**. | ||
|
||
!!! note "Технические детали" |
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.
детали –> подробности
* Затем он возвращает **ответ**. | ||
|
||
!!! note "Технические детали" | ||
Если у вас есть зависимости с `yield`, то код выхода (finally) будет выполняться *после* мидлвар. |
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.
выполНЕН
!!! note "Технические детали" | ||
Если у вас есть зависимости с `yield`, то код выхода (finally) будет выполняться *после* мидлвар. | ||
|
||
Если были фоновые задачи (описанные позже), то они будут выполняться *после* всех промежуточных программ. |
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.
(описанные НИЖЕ)
всех промежуточных программ –> всего промежуточного ПО
|
||
## Создание мидлвар | ||
|
||
Для создания мидлвар используется декоратор `@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.
можно просто "перед функцией" или "к функции применяется декоратор..."
|
||
Но если у вас есть пользовательские заголовки, чтобы их мог видеть клиент в браузере, вам необходимо добавить их в 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">документации по CORS в библиотеке Starlette</a>. | ||
|
||
!!! note "Технические детали" |
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.
детали –> подробности
|
||
**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.
вряд ли здесь стоит переводить Response, т.к. имеется в виду объект.
|
||
Более подробно о других мидлварах вы можете прочитать в разделе [Расширенное руководство пользователя: Продвинутый мидлвар](../advanced/middleware.md){.internal-link target=_blank}. | ||
|
||
О том, как управлять <abbr title="Cross-Origin Resource Sharing">CORS</abbr> с помощью мидлвар, вы узнаете в следующем разделе. |
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.
возможно, лучше "перехватывать"
As this PR had requested changes to be applied but has been inactive for a while, it's now going to be closed. But if there's anyone interested, feel free to create a new PR. |
sorry for the late response, and thank you
…________________________________
From: Sebastián Ramírez ***@***.***>
Sent: Wednesday, February 7, 2024 9:14 PM
To: tiangolo/fastapi ***@***.***>
Cc: Subscribed ***@***.***>
Subject: Re: [tiangolo/fastapi] 🌐 Add Russian translation for `docs/ru/docs/tutorial/middleware.md` (PR #10538)
Closed #10538<#10538>.
—
Reply to this email directly, view it on GitHub<#10538 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/BE7DINCA2ZJRXCJFUSDXFE3YSQ7LDAVCNFSM6AAAAAA6T7UBAOVHI2DSMVQWIX3LMV45UABCJFZXG5LFIV3GK3TUJZXXI2LGNFRWC5DJN5XDWMJRG42DAMRZGUZTQMQ>.
You are receiving this because you are subscribed to this thread.Message ID: ***@***.***>
|
No description provided.