Browse Source

๐ŸŒ Add Korean translation for Tutorial - Header Parameters (#2589)

Co-authored-by: Sebastiรกn Ramรญrez <[email protected]>
pull/3031/head
mode 4 years ago
committed by GitHub
parent
commit
5934a75ddd
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 90
      docs/ko/docs/tutorial/header-params.md
  2. 1
      docs/ko/mkdocs.yml

90
docs/ko/docs/tutorial/header-params.md

@ -0,0 +1,90 @@
# ํ—ค๋” ๋งค๊ฐœ๋ณ€์ˆ˜
ํ—ค๋” ๋งค๊ฐœ๋ณ€์ˆ˜๋ฅผ `Query`, `Path` ๊ทธ๋ฆฌ๊ณ  `Cookie` ๋งค๊ฐœ๋ณ€์ˆ˜๋“ค๊ณผ ๊ฐ™์€ ๋ฐฉ์‹์œผ๋กœ ์ •์˜ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
## `Header` ์ž„ํฌํŠธ
๋จผ์ € `Header`๋ฅผ ์ž„ํฌํŠธํ•ฉ๋‹ˆ๋‹ค:
```Python hl_lines="3"
{!../../../docs_src/header_params/tutorial001.py!}
```
## `Header` ๋งค๊ฐœ๋ณ€์ˆ˜ ์„ ์–ธ
`Path`, `Query` ๊ทธ๋ฆฌ๊ณ  `Cookie`๋ฅผ ์‚ฌ์šฉํ•œ ๋™์ผํ•œ ๊ตฌ์กฐ๋ฅผ ์ด์šฉํ•˜์—ฌ ํ—ค๋” ๋งค๊ฐœ๋ณ€์ˆ˜๋ฅผ ์„ ์–ธํ•ฉ๋‹ˆ๋‹ค.
์ฒซ ๋ฒˆ์งธ ๊ฐ’์€ ๊ธฐ๋ณธ๊ฐ’์ด๋ฉฐ, ์ถ”๊ฐ€ ๊ฒ€์ฆ์ด๋‚˜ ์–ด๋…ธํ…Œ์ด์…˜ ๋งค๊ฐœ๋ณ€์ˆ˜ ๋ชจ๋‘ ์ „๋‹ฌํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค:
```Python hl_lines="9"
{!../../../docs_src/header_params/tutorial001.py!}
```
!!! note "๊ธฐ์ˆ  ์„ธ๋ถ€์‚ฌํ•ญ"
`Header`๋Š” `Path`, `Query` ๋ฐ `Cookie`์˜ "์ž๋งค"ํด๋ž˜์Šค์ž…๋‹ˆ๋‹ค. ์ด ์—ญ์‹œ ๋™์ผํ•œ ๊ณตํ†ต `Param` ํด๋ž˜์Šค๋ฅผ ์ƒ์†ํ•ฉ๋‹ˆ๋‹ค.
`Query`, `Path`, `Header` ๊ทธ๋ฆฌ๊ณ  ๋‹ค๋ฅธ ๊ฒƒ๋“ค์„ `fastapi`์—์„œ ์ž„ํฌํŠธ ํ•  ๋•Œ, ์ด๋“ค์€ ์‹ค์ œ๋กœ ํŠน๋ณ„ํ•œ ํด๋ž˜์Šค๋ฅผ ๋ฐ˜ํ™˜ํ•˜๋Š” ํ•จ์ˆ˜์ž„์„ ๊ธฐ์–ตํ•˜์„ธ์š”.
!!! info "์ •๋ณด"
ํ—ค๋”๋ฅผ ์„ ์–ธํ•˜๊ธฐ ์œ„ํ•ด์„œ `Header`๋ฅผ ์‚ฌ์šฉํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. ๊ทธ๋ ‡์ง€ ์•Š์œผ๋ฉด ํ•ด๋‹น ๋งค๊ฐœ๋ณ€์ˆ˜๋ฅผ ์ฟผ๋ฆฌ ๋งค๊ฐœ๋ณ€์ˆ˜๋กœ ํ•ด์„ํ•˜๊ธฐ ๋•Œ๋ฌธ์ž…๋‹ˆ๋‹ค.
## ์ž๋™ ๋ณ€ํ™˜
`Header`๋Š” `Path`, `Query` ๊ทธ๋ฆฌ๊ณ  `Cookie`๊ฐ€ ์ œ๊ณตํ•˜๋Š” ๊ฒƒ ์™ธ์— ๊ธฐ๋Šฅ์ด ์กฐ๊ธˆ ๋” ์žˆ์Šต๋‹ˆ๋‹ค.
๋Œ€๋ถ€๋ถ„์˜ ํ‘œ์ค€ ํ—ค๋”๋Š” "๋งˆ์ด๋„ˆ์Šค ๊ธฐํ˜ธ" (`-`)๋ผ๊ณ ๋„ ํ•˜๋Š” "ํ•˜์ดํ”ˆ" ๋ฌธ์ž๋กœ ๊ตฌ๋ถ„๋ฉ๋‹ˆ๋‹ค.
๊ทธ๋Ÿฌ๋‚˜ ํŒŒ์ด์ฌ์—์„œ `user-agent`์™€ ๊ฐ™์€ ํ˜•ํƒœ์˜ ๋ณ€์ˆ˜๋Š” ์œ ํšจํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.
๋”ฐ๋ผ์„œ `Header`๋Š” ๊ธฐ๋ณธ์ ์œผ๋กœ ๋งค๊ฐœ๋ณ€์ˆ˜ ์ด๋ฆ„์„ ์–ธ๋”์Šค์ฝ”์–ด(`_`)์—์„œ ํ•˜์ดํ”ˆ(`-`)์œผ๋กœ ๋ณ€ํ™˜ํ•˜์—ฌ ํ—ค๋”๋ฅผ ์ถ”์ถœํ•˜๊ณ  ๊ธฐ๋กํ•ฉ๋‹ˆ๋‹ค.
๋˜ํ•œ HTTP ํ—ค๋”๋Š” ๋Œ€์†Œ๋ฌธ์ž๋ฅผ ๊ตฌ๋ถ„ํ•˜์ง€ ์•Š์œผ๋ฏ€๋กœ "snake_case"๋กœ ์•Œ๋ ค์ง„ ํ‘œ์ค€ ํŒŒ์ด์ฌ ์Šคํƒ€์ผ๋กœ ์„ ์–ธํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
๋”ฐ๋ผ์„œ, `User_Agent` ๋“ฑ๊ณผ ๊ฐ™์ด ์ฒซ ๋ฌธ์ž๋ฅผ ๋Œ€๋ฌธ์žํ™”ํ•  ํ•„์š”์—†์ด ํŒŒ์ด์ฌ ์ฝ”๋“œ์—์„œ์ฒ˜๋Ÿผ `user_agent`๋กœ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค.
๋งŒ์•ฝ ์–ธ๋”์Šค์ฝ”์–ด๋ฅผ ํ•˜์ดํ”ˆ์œผ๋กœ ์ž๋™ ๋ณ€ํ™˜์„ ๋น„ํ™œ์„ฑํ™”ํ•ด์•ผ ํ•  ์–ด๋–ค ์ด์œ ๊ฐ€ ์žˆ๋‹ค๋ฉด, `Header`์˜ `convert_underscores` ๋งค๊ฐœ๋ณ€์ˆ˜๋ฅผ `False`๋กœ ์„ค์ •ํ•˜์‹ญ์‹œ์˜ค:
```Python hl_lines="10"
{!../../../docs_src/header_params/tutorial002.py!}
```
!!! warning "๊ฒฝ๊ณ "
`convert_underscore`๋ฅผ `False`๋กœ ์„ค์ •ํ•˜๊ธฐ ์ „์—, ์–ด๋–ค HTTP ํ”„๋ก์‹œ๋“ค๊ณผ ์„œ๋ฒ„๋“ค์€ ์–ธ๋”์Šค์ฝ”์–ด๊ฐ€ ํฌํ•จ๋œ ํ—ค๋” ์‚ฌ์šฉ์„ ํ—ˆ๋ฝํ•˜์ง€ ์•Š๋Š”๋‹ค๋Š” ๊ฒƒ์„ ๋ช…์‹ฌํ•˜์‹ญ์‹œ์˜ค.
## ์ค‘๋ณต ํ—ค๋”
์ค‘๋ณต ํ—ค๋”๋“ค์„ ์ˆ˜์‹ ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์ฆ‰, ๋‹ค์ค‘๊ฐ’์„ ๊ฐ–๋Š” ๋™์ผํ•œ ํ—ค๋”๋ฅผ ๋œปํ•ฉ๋‹ˆ๋‹ค.
ํƒ€์ž… ์ •์˜์—์„œ ๋ฆฌ์ŠคํŠธ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์ด๋Ÿฌํ•œ ์ผ€์ด์Šค๋ฅผ ์ •์˜ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
์ค‘๋ณต ํ—ค๋”์˜ ๋ชจ๋“  ๊ฐ’์„ ํŒŒ์ด์ฌ `list`๋กœ ์ˆ˜์‹ ํ•ฉ๋‹ˆ๋‹ค.
์˜ˆ๋ฅผ ๋“ค์–ด, ๋‘ ๋ฒˆ ์ด์ƒ ๋‚˜ํƒ€๋‚  ์ˆ˜ ์žˆ๋Š” `X-Token`ํ—ค๋”๋ฅผ ์„ ์–ธํ•˜๋ ค๋ฉด, ๋‹ค์Œ๊ณผ ๊ฐ™์ด ์ž‘์„ฑํ•ฉ๋‹ˆ๋‹ค:
```Python hl_lines="9"
{!../../../docs_src/header_params/tutorial003.py!}
```
๋‹ค์Œ๊ณผ ๊ฐ™์€ ๋‘ ๊ฐœ์˜ HTTP ํ—ค๋”๋ฅผ ์ „์†กํ•˜์—ฌ ํ•ด๋‹น *๊ฒฝ๋กœ* ์™€ ํ†ต์‹ ํ•  ๊ฒฝ์šฐ:
```
X-Token: foo
X-Token: bar
```
์‘๋‹ต์€ ๋‹ค์Œ๊ณผ ๊ฐ™์Šต๋‹ˆ๋‹ค:
```JSON
{
"X-Token values": [
"bar",
"foo"
]
}
```
## ์š”์•ฝ
`Header`๋Š” `Query`, `Path`, `Cookie`์™€ ๋™์ผํ•œ ํŒจํ„ด์„ ์‚ฌ์šฉํ•˜์—ฌ ์„ ์–ธํ•ฉ๋‹ˆ๋‹ค.
๋ณ€์ˆ˜์˜ ์–ธ๋”์Šค์ฝ”์–ด๋ฅผ ๊ฑฑ์ •ํ•˜์ง€ ๋งˆ์‹ญ์‹œ์˜ค, **FastAPI**๊ฐ€ ๋ณ€์ˆ˜๋ฅผ ๋ณ€ํ™˜ํ•  ๊ฒƒ์ž…๋‹ˆ๋‹ค.

1
docs/ko/mkdocs.yml

@ -53,6 +53,7 @@ nav:
- ์ž์Šต์„œ - ์‚ฌ์šฉ์ž ์•ˆ๋‚ด์„œ:
- tutorial/index.md
- tutorial/first-steps.md
- tutorial/header-params.md
markdown_extensions:
- toc:
permalink: true

Loadingโ€ฆ
Cancel
Save