Browse Source

๐ŸŒ Add Korean Translation for `docs/ko/docs/advanced/response-cookies.md` (#12546)

pull/12676/merge
kim-sangah 5 months ago
committed by GitHub
parent
commit
3f822818b2
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 53
      docs/ko/docs/advanced/response-cookies.md

53
docs/ko/docs/advanced/response-cookies.md

@ -0,0 +1,53 @@
# ์‘๋‹ต ์ฟ ํ‚ค
## `Response` ๋งค๊ฐœ๋ณ€์ˆ˜ ์‚ฌ์šฉํ•˜๊ธฐ
*๊ฒฝ๋กœ ์ž‘๋™ ํ•จ์ˆ˜*์—์„œ `Response` ํƒ€์ž…์˜ ๋งค๊ฐœ๋ณ€์ˆ˜๋ฅผ ์„ ์–ธํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
๊ทธ๋Ÿฐ ๋‹ค์Œ ํ•ด๋‹น *์ž„์‹œ* ์‘๋‹ต ๊ฐ์ฒด์—์„œ ์ฟ ํ‚ค๋ฅผ ์„ค์ •ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
```Python hl_lines="1 8-9"
{!../../docs_src/response_cookies/tutorial002.py!}
```
๊ทธ๋Ÿฐ ๋‹ค์Œ ํ•„์š”ํ•œ ๊ฐ์ฒด(`dict`, ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค ๋ชจ๋ธ ๋“ฑ)๋ฅผ ๋ฐ˜ํ™˜ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
๊ทธ๋ฆฌ๊ณ  `response_model`์„ ์„ ์–ธํ–ˆ๋‹ค๋ฉด ๋ฐ˜ํ™˜ํ•œ ๊ฐ์ฒด๋ฅผ ๊ฑฐ๋ฅด๊ณ  ๋ณ€ํ™˜ํ•˜๋Š” ๋ฐ ์—ฌ์ „ํžˆ ์‚ฌ์šฉ๋ฉ๋‹ˆ๋‹ค.
**FastAPI**๋Š” ๊ทธ *์ž„์‹œ* ์‘๋‹ต์—์„œ ์ฟ ํ‚ค(๋˜ํ•œ ํ—ค๋” ๋ฐ ์ƒํƒœ ์ฝ”๋“œ)๋ฅผ ์ถ”์ถœํ•˜๊ณ , ๋ฐ˜ํ™˜๋œ ๊ฐ’์ด ํฌํ•จ๋œ ์ตœ์ข… ์‘๋‹ต์— ์ด๋ฅผ ๋„ฃ์Šต๋‹ˆ๋‹ค. ์ด ๊ฐ’์€ `response_model`๋กœ ๊ฑธ๋Ÿฌ์ง€๊ฒŒ ๋ฉ๋‹ˆ๋‹ค.
๋˜ํ•œ ์˜์กด๊ด€๊ณ„์—์„œ `Response` ๋งค๊ฐœ๋ณ€์ˆ˜๋ฅผ ์„ ์–ธํ•˜๊ณ , ํ•ด๋‹น ์˜์กด์„ฑ์—์„œ ์ฟ ํ‚ค(๋ฐ ํ—ค๋”)๋ฅผ ์„ค์ •ํ•  ์ˆ˜๋„ ์žˆ์Šต๋‹ˆ๋‹ค.
## `Response`๋ฅผ ์ง์ ‘ ๋ฐ˜ํ™˜ํ•˜๊ธฐ
์ฝ”๋“œ์—์„œ `Response`๋ฅผ ์ง์ ‘ ๋ฐ˜ํ™˜ํ•  ๋•Œ๋„ ์ฟ ํ‚ค๋ฅผ ์ƒ์„ฑํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
์ด๋ฅผ ์œ„ํ•ด [Response๋ฅผ ์ง์ ‘ ๋ฐ˜ํ™˜ํ•˜๊ธฐ](response-directly.md){.internal-link target=_blank}์—์„œ ์„ค๋ช…ํ•œ ๋Œ€๋กœ ์‘๋‹ต์„ ์ƒ์„ฑํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
๊ทธ๋Ÿฐ ๋‹ค์Œ ์ฟ ํ‚ค๋ฅผ ์„ค์ •ํ•˜๊ณ  ๋ฐ˜ํ™˜ํ•˜๋ฉด ๋ฉ๋‹ˆ๋‹ค:
```Python hl_lines="1 18"
{!../../docs_src/response_directly/tutorial002.py!}
```
/// tip
`Response` ๋งค๊ฐœ๋ณ€์ˆ˜๋ฅผ ์‚ฌ์šฉํ•˜์ง€ ์•Š๊ณ  ์‘๋‹ต์„ ์ง์ ‘ ๋ฐ˜ํ™˜ํ•˜๋Š” ๊ฒฝ์šฐ, FastAPI๋Š” ์ด๋ฅผ ์ง์ ‘ ๋ฐ˜ํ™˜ํ•œ๋‹ค๋Š” ์ ์— ์œ ์˜ํ•˜์„ธ์š”.
๋”ฐ๋ผ์„œ ๋ฐ์ดํ„ฐ๊ฐ€ ์˜ฌ๋ฐ”๋ฅธ ์œ ํ˜•์ธ์ง€ ํ™•์ธํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. ์˜ˆ: `JSONResponse`๋ฅผ ๋ฐ˜ํ™˜ํ•˜๋Š” ๊ฒฝ์šฐ, JSON๊ณผ ํ˜ธํ™˜๋˜๋Š”์ง€ ํ™•์ธํ•˜์„ธ์š”.
๋˜ํ•œ `response_model`๋กœ ๊ฑธ๋Ÿฌ์ ธ์•ผ ํ•  ๋ฐ์ดํ„ฐ๊ฐ€ ์ „๋‹ฌ๋˜์ง€ ์•Š๋„๋ก ํ™•์ธํ•˜์„ธ์š”.
///
### ์ถ”๊ฐ€ ์ •๋ณด
/// note | "๊ธฐ์ˆ ์  ์„ธ๋ถ€์‚ฌํ•ญ"
`from starlette.responses import Response` ๋˜๋Š” `from starlette.responses import JSONResponse`๋ฅผ ์‚ฌ์šฉํ•  ์ˆ˜๋„ ์žˆ์Šต๋‹ˆ๋‹ค.
**FastAPI**๋Š” ๊ฐœ๋ฐœ์ž์˜ ํŽธ์˜๋ฅผ ์œ„ํ•ด `fastapi.responses`๋กœ ๋™์ผํ•œ `starlette.responses`๋ฅผ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค. ๊ทธ๋Ÿฌ๋‚˜ ๋Œ€๋ถ€๋ถ„์˜ ์‘๋‹ต์€ Starlette์—์„œ ์ง์ ‘ ์ œ๊ณต๋ฉ๋‹ˆ๋‹ค.
๋˜ํ•œ `Response`๋Š” ํ—ค๋”์™€ ์ฟ ํ‚ค๋ฅผ ์„ค์ •ํ•˜๋Š” ๋ฐ ์ž์ฃผ ์‚ฌ์šฉ๋˜๋ฏ€๋กœ, **FastAPI**๋Š” ์ด๋ฅผ `fastapi.Response`๋กœ๋„ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค.
///
์‚ฌ์šฉ ๊ฐ€๋Šฅํ•œ ๋ชจ๋“  ๋งค๊ฐœ๋ณ€์ˆ˜์™€ ์˜ต์…˜์€ <a href="https://www.starlette.io/responses/#set-cookie" class="external-link" target="_blank">Starlette ๋ฌธ์„œ</a>์—์„œ ํ™•์ธํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
Loadingโ€ฆ
Cancel
Save