Skip to content
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 Korean translation for docs/ko/docs/tutorial/middleware.md #2829

Merged
merged 31 commits into from
Jan 31, 2024
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
4c72d00
Add Korean Translation for Tutorial - Middleware
JeongHyeongKim Feb 18, 2021
a2ee84a
update some words
JeongHyeongKim Feb 18, 2021
8ebda36
apply feedback
JeongHyeongKim Mar 2, 2021
b1d721f
apply feedback
JeongHyeongKim Mar 2, 2021
6bfb733
remove term '당신'
JeongHyeongKim Mar 2, 2021
0f2c891
modity format to en
JeongHyeongKim Mar 2, 2021
6b31dc6
Update docs/ko/docs/tutorial/middleware.md
JeongHyeongKim May 11, 2021
1695e7f
Update docs/ko/docs/tutorial/middleware.md
JeongHyeongKim May 11, 2021
1efab28
Update docs/ko/docs/tutorial/middleware.md
JeongHyeongKim May 11, 2021
556dada
Merge branch 'master' into master
JeongHyeongKim May 11, 2021
7146aec
Update docs/ko/docs/tutorial/middleware.md
JeongHyeongKim May 11, 2021
a892b90
Update docs/ko/docs/tutorial/middleware.md
JeongHyeongKim May 11, 2021
dc771bd
Merge branch 'tiangolo:master' into master
JeongHyeongKim Jul 7, 2021
7e1f926
Merge branch 'tiangolo:master' into master
JeongHyeongKim Aug 19, 2021
1f301c2
Merge branch 'tiangolo:master' into master
JeongHyeongKim Sep 2, 2021
116f2a7
Merge branch 'tiangolo:master' into master
JeongHyeongKim Sep 11, 2021
a77f979
Update docs/ko/docs/tutorial/middleware.md
JeongHyeongKim Dec 9, 2021
be6aa46
Update docs/ko/docs/tutorial/middleware.md
JeongHyeongKim Dec 9, 2021
dcd077d
Update docs/ko/docs/tutorial/middleware.md
JeongHyeongKim Dec 9, 2021
4ca3ac7
Update docs/ko/docs/tutorial/middleware.md
JeongHyeongKim Dec 9, 2021
02944dd
Update docs/ko/docs/tutorial/middleware.md
JeongHyeongKim Dec 9, 2021
b5b09b7
Update docs/ko/docs/tutorial/middleware.md
JeongHyeongKim Dec 9, 2021
470b1e6
Update docs/ko/docs/tutorial/middleware.md
JeongHyeongKim Dec 9, 2021
1faa465
Update docs/ko/docs/tutorial/middleware.md
JeongHyeongKim Dec 9, 2021
0d7f133
Update docs/ko/docs/tutorial/middleware.md
JeongHyeongKim Dec 9, 2021
3c5bd36
Update docs/ko/docs/tutorial/middleware.md
JeongHyeongKim Dec 9, 2021
15fe78f
Merge branch 'master' into master
JeongHyeongKim Dec 9, 2021
02f34f3
Update middleware.md
JeongHyeongKim Dec 9, 2021
d8bd0ec
Merge branch 'master' into master
JeongHyeongKim Sep 23, 2022
2241794
Merge branch 'master' into master
tiangolo Dec 16, 2022
9e0718c
Merge branch 'master' into master
tiangolo Jun 26, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
61 changes: 61 additions & 0 deletions docs/ko/docs/tutorial/middleware.md
@@ -0,0 +1,61 @@
# 미들웨어

미들웨어를 **FastAPI** 애플리케이션에 추가할 수 있습니다.
JeongHyeongKim marked this conversation as resolved.
Show resolved Hide resolved

"미들웨어"는 특정 *경로 동작*에 의해 처리되기 전, 모든 **요청**에 대해서 동작하는 함수입니다. 또한 모든 **응답**이 반환되기 전에도 동일하게 동작합니다.
JeongHyeongKim marked this conversation as resolved.
Show resolved Hide resolved

* 미들웨어는 애플리케이션으로 오는 **요청**를 가져옵니다.
JeongHyeongKim marked this conversation as resolved.
Show resolved Hide resolved
* **요청** 또는 다른 필요한 코드를 실행 시키는 동작을 할 수 있습니다.
JeongHyeongKim marked this conversation as resolved.
Show resolved Hide resolved
* **요청**을 애플리케이션의 *경로 작업*으로 전달하여 처리합니다.
JeongHyeongKim marked this conversation as resolved.
Show resolved Hide resolved
* 애플리케이션의 *경로 작업*에서 생성한 **응답**를 받습니다.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
* 애플리케이션의 *경로 작업*에서 생성한 **응답**를 받습니다.
* 애플리케이션의 *경로 작동*에서 생성한 **응답**를 받습니다.

* **응답** 또는 다른 필요한 코드를 실행시키는 동작을 할 수 있습니다.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
* **응답** 또는 다른 필요한 코드를 실행시키는 동작을 할 수 있습니다.
* **응답** 또는 다른 필요한 코드를 실행시킬 수 있습니다.

* **응답**를 반환합니다.

!!! note "기술 세부사항"
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
!!! note "기술 세부사항"
!!! note "기술적 세부사항"

And also check 파이썬 공식 한국어 문서에 없는 용어 중 현재 사용하고 있는 용어 in #3167 .

만약 `yield`를 사용한 의존성을 가지고 있다면, 미들웨어가 실행되고 난 후에 exit이 실행됩니다.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
만약 `yield`를 사용한 의존성을 가지고 있다면, 미들웨어가 실행되고 난 후에 exit이 실행됩니다.
만약 `yield`를 사용한 의존성을 가지고 있다면, 미들웨어가 실행되고 *난 후에* 종료 코드가 실행됩니다.

use less English as you can.

Check #2017 .


만약 (나중에 문서에서 다룰) 백그라운드 작업이 있다면, 모든 미들웨어가 실행되고 *난 후에* 실행됩니다.

## 미들웨어 만들기
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
## 미들웨어 만들기
## 미들웨어 생성

I prefer 생성 to 만들기 because 생성 is a pure noun.


미들웨어를 작성하기 위해서 함수 상단에 `@app.middleware("http")` 데코레이터를 사용할 수 있습니다.

미들웨어 함수는 다음 항목들을 받습니다:

* `request`.
* `request`를 매개변수로 받는 `call_next` 함수.
* 이 함수는 `request`를 해당하는 *경로 작업*으로 전달합니다.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
* 이 함수는 `request`를 해당하는 *경로 작업*으로 전달합니다.
* 이 함수는 `request`를 해당하는 *경로 작동*으로 전달합니다.

* 그런 다음, *경로 작업*에 의해 생성된 `response` 를 반환합니다.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
* 그런 다음, *경로 작업*에 의해 생성된 `response` 를 반환합니다.
* 그런 다음, *경로 작동*에 의해 생성된 `response` 를 반환합니다.

* `response`를 반환하기 전에 추가로 `response`를 수정할 수 있습니다.

```Python hl_lines="8-9 11 14"
{!../../../docs_src/middleware/tutorial001.py!}
```

!!! 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})에 <a href="https://www.starlette.io/middleware/#corsmiddleware" class="external-link" target="_blank">Starlette CORS 문서</a>에 명시된 `expose_headers` 매개변수를 이용하여 헤더들을 추가하여야합니다.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
그러나 만약 클라이언트의 브라우저에서 볼 수 있는 사용자 정의 헤더를 가지고 있다면, 그것들을 CORS 설정([CORS (Cross-Origin Resource Sharing)](cors.md){.internal-link target=_blank})에 <a href="https://www.starlette.io/middleware/#corsmiddleware" class="external-link" target="_blank">Starlette CORS 문서</a>에 명시된 `expose_headers` 매개변수를 이용하여 헤더들을 추가하여야합니다.
그러나 만약 클라이언트의 브라우저에서 볼 수 있는 사용자 정의 헤더를 가지고 있다면, 그것들을 CORS 설정([CORS (교차-출처 리소스 공유)](cors.md){.internal-link target=_blank})에 <a href="https://www.starlette.io/middleware/#corsmiddleware" class="external-link" target="_blank">Starlette CORS 문서</a>에 명시된 `expose_headers` 매개변수를 이용하여 헤더들을 추가하여야합니다.


!!! note "기술 세부사항"
JeongHyeongKim marked this conversation as resolved.
Show resolved Hide resolved
`from starlette.requests import request`를 사용할 수도 있습니다.

**FastAPI**는 개발자에게 편의를 위해 이를 제공합니다. 그러나 Starlette에서 직접 파생되었습니다.

### `response`의 전과 후

*경로 작업*을 받기 전 `request`와 함께 동작할 수 있는 코드를 추가할 수 있습니다.
JeongHyeongKim marked this conversation as resolved.
Show resolved Hide resolved

그리고 `response` 또한 생성된 후 반환되기 전에 코드를 추가 할 수 있습니다.

예를 들어, 요청을 수행하고 응답을 생성하는데 까지 걸린 시간 값을 가지고 있는 `X-Process-Time` 같은 사용자 정의 헤더를 추가할 수 있습니다.

```Python hl_lines="10 12-13"
{!../../../docs_src/middleware/tutorial001.py!}
```

## 그 이외의 미들웨어
JeongHyeongKim marked this conversation as resolved.
Show resolved Hide resolved

미들웨어 대한 더 많은 정보를 [고급 사용 가이드: 향상된 미들웨어](../advanced/middleware.md){.internal-link target=\_blank}에서 읽을 수 있습니다.
JeongHyeongKim marked this conversation as resolved.
Show resolved Hide resolved

다음 섹션에서 미들웨어를 어떻게 다루는지에 대해 읽을 것입니다.
JeongHyeongKim marked this conversation as resolved.
Show resolved Hide resolved
1 change: 1 addition & 0 deletions docs/ko/mkdocs.yml
Expand Up @@ -57,6 +57,7 @@ nav:
- tutorial/path-params.md
- tutorial/query-params.md
- tutorial/header-params.md
- tutorial/middleware.md
markdown_extensions:
- toc:
permalink: true
Expand Down