REST, RESTful

๋ฐฐํ•œ๋นˆยท2023๋…„ 3์›” 12์ผ
9
post-custom-banner

๐Ÿ’ก ํ”„๋ก ํŠธ์—”๋“œ ๊ฐœ๋ฐœ์ž๋ฅผ ์ค€๋น„ํ•˜๋‹ค๋ณด๋ฉด REST๋‚˜ RESTful์ด๋ž€ ๋‹จ์–ด๋ฅผ ์ž์ฃผ ๋“ค์–ด๋ดค์„ ๊ฒƒ์ด๋‹ค. ๋”ฐ๋ผ์„œ REST๊ฐ€ ๋ฌด์—‡์ด๊ณ  ์–ด๋–ป๊ฒŒ ์“ฐ์ด๋Š”์ง€ ์•Œ์•„๋ณด๊ณ ์ž ํ•œ๋‹ค.

ํ•œ๋งˆ๋””๋กœ?

  • Representational State Transfer (ํ‘œํ˜„ ์ƒํƒœ๋ฅผ ๋ณ€๊ฒฝ)
  • REST๋Š” ์›น์—์„œ ๋ฐ์ดํ„ฐ๋ฅผ ์ „์†กํ•˜๊ณ  ์ฒ˜๋ฆฌํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ์ •์˜ํ•œ ์ธํ„ฐํŽ˜์ด์Šค

๊ธฐ๋Šฅ

  1. Layered System(๊ณ„์ธต ๊ตฌ์กฐ)
    • REST Server๋Š” ๋‹ค์ค‘ ๊ณ„์ธต์œผ๋กœ ๊ตฌ์„ฑ ๊ฐ€๋Šฅ
      • ๋ณด์•ˆ, ๋กœ๋“œ ๋ฐธ๋Ÿฐ์‹ฑ, ์•”ํ˜ธํ™” ๋“ฑ์„ ์œ„ํ•œ ๊ณ„์ธต์„ ์ถ”๊ฐ€ํ•˜์—ฌ ๊ตฌ์กฐ ๋ณ€๊ฒฝ ๊ฐ€๋Šฅ
      • Proxy, Gateway์™€ ๊ฐ™์€ ๋„คํŠธ์›Œํฌ ๊ธฐ๋ฐ˜์˜ ์ค‘๊ฐ„๋งค์ฒด ์‚ฌ์šฉ ๊ฐ€๋Šฅ
  2. Uniform Interface(์ธํ„ฐํŽ˜์ด์Šค ์ผ๊ด€์„ฑ)
    • HTTP ํ‘œ์ค€ ํ”„๋กœํ† ์ฝœ์— ๋”ฐ๋ฅด๋Š” ๋ชจ๋“  ํ”Œ๋žซํผ์—์„œ ์‚ฌ์šฉ ๊ฐ€๋Šฅ, Loosely Coupling โ‡’ ํŠน์ • ์–ธ์–ด๋‚˜ ๊ธฐ์ˆ ์— ์ข…์† X
  3. Self-Descriptiveness(์ž์ฒด ํ‘œํ˜„)
    • ์š”์ฒญ ๋ฉ”์‹œ์ง€๋งŒ ๋ณด๊ณ ๋„ ์‰ฝ๊ฒŒ ์ดํ•ดํ•  ์ˆ˜ ์žˆ๋Š” ์ž์ฒด ํ‘œํ˜„ ๊ตฌ์กฐ

๋””์ž์ธ ๊ฐ€์ด๋“œ

  • URI๋Š” ์ •๋ณด์˜ ์ž์›์„ ํ‘œํ˜„ํ•ด์•ผ ํ•œ๋‹ค.
  • ์ž์›์— ๋Œ€ํ•œ ํ–‰์œ„๋Š” HTTP Method(GET, POST, PUT, PATCH, DELETE)๋กœ ํ‘œํ˜„ํ•œ๋‹ค.
    • ํ–‰์œ„(Method)๋Š” URI์— ํฌํ•จํ•˜์ง€ ์•Š๋Š”๋‹ค.

์„ค๊ณ„ ๊ทœ์น™

  1. URI๋Š” ๋ช…์‚ฌ๋ฅผ ์‚ฌ์šฉ(๋ฆฌ์†Œ์Šค๋ช…์€ ๋™์‚ฌ๊ฐ€ ์•„๋‹Œ ๋ช…์‚ฌ๋ฅผ ์‚ฌ์šฉํ•ด์•ผ ํ•œ๋‹ค.)
  2. /๋กœ ๊ณ„์ธต ๊ด€๊ณ„ ํ‘œํ˜„ํ•œ๋‹ค.
  3. URI ๋งˆ์ง€๋ง‰ ๋ฌธ์ž๋กœ /๋ฅผ ํฌํ•จํ•˜์ง€ ์•Š๋Š”๋‹ค.
  4. _๋ฅผ ์‚ฌ์šฉํ•˜์ง€ ์•Š๊ณ , -์„ ์‚ฌ์šฉํ•œ๋‹ค.
  5. URI๋Š” ์†Œ๋ฌธ์ž๋กœ๋งŒ ๊ตฌ์„ฑ
  6. HTTP ์‘๋‹ต ์ƒํƒœ ์ฝ”๋“œ ์‚ฌ์šฉ
  7. ํŒŒ์ผ ํ™•์žฅ์ž๋Š” URI์— ํฌํ•จํ•˜์ง€ ์•Š์Œ

RESTful API

REST์˜ ์›๋ฆฌ๋ฅผ ์ž˜ ๋”ฐ๋ฅด๋Š” ์‹œ์Šคํ…œ

๊ฐœ๋…

  • REST ์•„ํ‚คํ…์ฒ˜๋ฅผ ๊ตฌํ˜„ํ•˜๋Š” ์›น ์„œ๋น„์Šค๋ฅผ ๋‚˜ํƒ€๋‚ด๊ธฐ ์œ„ํ•ด ์‚ฌ์šฉ๋˜๋Š” ์šฉ์–ด
  • REST๋ฅผ REST ๋‹ต๊ฒŒ ์“ฐ๊ธฐ ์œ„ํ•œ ๋ฐฉ๋ฒ•์œผ๋กœ, ๋ˆ„๊ตฐ๊ฐ€๊ฐ€ ๊ณต์‹์ ์œผ๋กœ ๋ฐœํ‘œํ•œ ๊ฒƒ์ด ์•„๋‹˜

[์ฐธ๊ณ ]

http://www.incodom.kr/REST

https://dev-coco.tistory.com/97

https://gmlwjd9405.github.io/2018/09/21/rest-and-restful.html

profile
์„ฑ์žฅ์„ ์ฆ๊ธฐ๋Š” ๊ฐœ๋ฐœ์ž, ๋ฐฐํ•œ๋นˆ์ž…๋‹ˆ๋‹ค.
post-custom-banner

0๊ฐœ์˜ ๋Œ“๊ธ€