Browse Source

๐ŸŒ Add Korean translation for `docs/ko/docs/advanced/using_request_directly.md` (#12738)

pull/12794/head
LKY 5 months ago
committed by GitHub
parent
commit
c5ff950dfc
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 58
      docs/ko/docs/advanced/using-request-directly.md

58
docs/ko/docs/advanced/using-request-directly.md

@ -0,0 +1,58 @@
# `Request` ์ง์ ‘ ์‚ฌ์šฉํ•˜๊ธฐ
์ง€๊ธˆ๊นŒ์ง€ ์š”์ฒญ์—์„œ ํ•„์š”ํ•œ ๋ถ€๋ถ„์„ ๊ฐ ํƒ€์ž…์œผ๋กœ ์„ ์–ธํ•˜์—ฌ ์‚ฌ์šฉํ•ด ์™”์Šต๋‹ˆ๋‹ค.
๋‹ค์Œ๊ณผ ๊ฐ™์€ ๊ณณ์—์„œ ๋ฐ์ดํ„ฐ๋ฅผ ๊ฐ€์ ธ์™”์Šต๋‹ˆ๋‹ค:
* ๊ฒฝ๋กœ์˜ ํŒŒ๋ผ๋ฏธํ„ฐ๋กœ๋ถ€ํ„ฐ.
* ํ—ค๋”.
* ์ฟ ํ‚ค.
* ๊ธฐํƒ€ ๋“ฑ๋“ฑ.
์ด๋ ‡๊ฒŒ ํ•จ์œผ๋กœ์จ, **FastAPI**๋Š” ๋ฐ์ดํ„ฐ๋ฅผ ๊ฒ€์ฆํ•˜๊ณ  ๋ณ€ํ™˜ํ•˜๋ฉฐ, API์— ๋Œ€ํ•œ ๋ฌธ์„œ๋ฅผ ์ž๋™ํ™”๋กœ ์ƒ์„ฑํ•ฉ๋‹ˆ๋‹ค.
ํ•˜์ง€๋งŒ `Request` ๊ฐ์ฒด์— ์ง์ ‘ ์ ‘๊ทผํ•ด์•ผ ํ•˜๋Š” ์ƒํ™ฉ์ด ์žˆ์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
## `Request` ๊ฐ์ฒด์— ๋Œ€ํ•œ ์„ธ๋ถ€ ์‚ฌํ•ญ
**FastAPI**๋Š” ์‹ค์ œ๋กœ ๋‚ด๋ถ€์— **Starlette**์„ ์‚ฌ์šฉํ•˜๋ฉฐ, ๊ทธ ์œ„์— ์—ฌ๋Ÿฌ ๋„๊ตฌ๋ฅผ ๋ง๋ถ™์ธ ๊ตฌ์กฐ์ž…๋‹ˆ๋‹ค. ๋”ฐ๋ผ์„œ ์—ฌ๋Ÿฌ๋ถ„์ด ํ•„์š”ํ•  ๋•Œ Starlette์˜ <a href="https://www.starlette.io/requests/" class="external-link" target="_blank">`Request`</a> ๊ฐ์ฒด๋ฅผ ์ง์ ‘ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
`Request` ๊ฐ์ฒด์—์„œ ๋ฐ์ดํ„ฐ๋ฅผ ์ง์ ‘ ๊ฐ€์ ธ์˜ค๋Š” ๊ฒฝ์šฐ(์˜ˆ: ๋ณธ๋ฌธ์„ ์ฝ๊ธฐ)์—๋Š” FastAPI๊ฐ€ ํ•ด๋‹น ๋ฐ์ดํ„ฐ๋ฅผ ๊ฒ€์ฆํ•˜๊ฑฐ๋‚˜ ๋ณ€ํ™˜ํ•˜์ง€ ์•Š์œผ๋ฉฐ, ๋ฌธ์„œํ™”(OpenAPI๋ฅผ ํ†ตํ•œ ๋ฌธ์„œ ์ž๋™ํ™”(๋กœ ์ƒ์„ฑ๋œ) API ์‚ฌ์šฉ์ž ์ธํ„ฐํŽ˜์ด์Šค)๋„ ๋˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.
๊ทธ๋Ÿฌ๋‚˜ ๋‹ค๋ฅธ ๋งค๊ฐœ๋ณ€์ˆ˜(์˜ˆ: Pydantic ๋ชจ๋ธ์„ ์‚ฌ์šฉํ•œ ๋ณธ๋ฌธ)๋Š” ์—ฌ์ „ํžˆ ๊ฒ€์ฆ, ๋ณ€ํ™˜, ์ฃผ์„ ์ถ”๊ฐ€ ๋“ฑ์ด ์ด๋ฃจ์–ด์ง‘๋‹ˆ๋‹ค.
ํ•˜์ง€๋งŒ ํŠน์ •ํ•œ ๊ฒฝ์šฐ์—๋Š” `Request` ๊ฐ์ฒด์— ์ง์ ‘ ์ ‘๊ทผํ•˜๋Š” ๊ฒƒ์ด ์œ ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
## `Request` ๊ฐ์ฒด๋ฅผ ์ง์ ‘ ์‚ฌ์šฉํ•˜๊ธฐ
์—ฌ๋Ÿฌ๋ถ„์ด ํด๋ผ์ด์–ธํŠธ์˜ IP ์ฃผ์†Œ/ํ˜ธ์ŠคํŠธ ์ •๋ณด๋ฅผ *๊ฒฝ๋กœ ์ž‘๋™ ํ•จ์ˆ˜* ๋‚ด๋ถ€์—์„œ ๊ฐ€์ ธ์™€์•ผ ํ•œ๋‹ค๊ณ  ๊ฐ€์ •ํ•ด ๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค.
์ด๋ฅผ ์œ„ํ•ด์„œ๋Š” ์š”์ฒญ์— ์ง์ ‘ ์ ‘๊ทผํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.
```Python hl_lines="1 7-8"
{!../../docs_src/using_request_directly/tutorial001.py!}
```
*๊ฒฝ๋กœ ์ž‘๋™ ํ•จ์ˆ˜* ๋งค๊ฐœ๋ณ€์ˆ˜๋ฅผ `Request` ํƒ€์ž…์œผ๋กœ ์„ ์–ธํ•˜๋ฉด **FastAPI**๊ฐ€ ํ•ด๋‹น ๋งค๊ฐœ๋ณ€์ˆ˜์— `Request` ๊ฐ์ฒด๋ฅผ ์ „๋‹ฌํ•˜๋Š” ๊ฒƒ์„ ์•Œ๊ฒŒ ๋ฉ๋‹ˆ๋‹ค.
/// tip | ํŒ
์ด ๊ฒฝ์šฐ, ์š”์ฒญ ๋งค๊ฐœ๋ณ€์ˆ˜์™€ ํ•จ๊ป˜ ๊ฒฝ๋กœ ๋งค๊ฐœ๋ณ€์ˆ˜๋ฅผ ์„ ์–ธํ•œ ๊ฒƒ์„ ๋ณผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
๋”ฐ๋ผ์„œ, ๊ฒฝ๋กœ ๋งค๊ฐœ๋ณ€์ˆ˜๋Š” ์ถ”์ถœ๋˜๊ณ  ๊ฒ€์ฆ๋˜๋ฉฐ ์ง€์ •๋œ ํƒ€์ž…์œผ๋กœ ๋ณ€ํ™˜๋˜๊ณ  OpenAPI๋กœ ์ฃผ์„์ด ์ถ”๊ฐ€๋ฉ๋‹ˆ๋‹ค.
์ด์™€ ๊ฐ™์€ ๋ฐฉ์‹์œผ๋กœ, ๋‹ค๋ฅธ ๋งค๊ฐœ๋ณ€์ˆ˜๋“ค์„ ํ‰์†Œ์ฒ˜๋Ÿผ ์„ ์–ธํ•˜๋ฉด์„œ, ๋ถ€๊ฐ€์ ์œผ๋กœ `Request`๋„ ๊ฐ€์ ธ์˜ฌ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
///
## `Request` ์„ค๋ช…์„œ
์—ฌ๋Ÿฌ๋ถ„์€ `Request` ๊ฐ์ฒด์— ๋Œ€ํ•œ ๋” ์ž์„ธํ•œ ๋‚ด์šฉ์„ <a href="https://www.starlette.io/requests/" class="external-link" target="_blank">๊ณต์‹ Starlette ์„ค๋ช…์„œ ์‚ฌ์ดํŠธ</a>์—์„œ ์ฝ์–ด๋ณผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
/// note | ๊ธฐ์ˆ  ์„ธ๋ถ€์‚ฌํ•ญ
`from starlette.requests import Request`๋ฅผ ์‚ฌ์šฉํ•  ์ˆ˜๋„ ์žˆ์Šต๋‹ˆ๋‹ค.
**FastAPI**๋Š” ์—ฌ๋Ÿฌ๋ถ„(๊ฐœ๋ฐœ์ž)๋ฅผ ์œ„ํ•œ ํŽธ์˜๋ฅผ ์œ„ํ•ด ์ด๋ฅผ ์ง์ ‘ ์ œ๊ณตํ•˜์ง€๋งŒ, ์‹ค์ œ๋กœ๋Š” Starlette์—์„œ ๊ฐ€์ ธ์˜จ ๊ฒƒ์ž…๋‹ˆ๋‹ค.
///
Loadingโ€ฆ
Cancel
Save