SlideShare una empresa de Scribd logo
1 de 54
Descargar para leer sin conexión
REST
그 쓸쓸함에 대하여…
강우
kangwoo@gmail.com
REST가 뭘까?
REpresentational
State Transfer
REpresentational
표현 하려면
뭐가 필요할까?
Resource
Physical / Virtual Resources
Identifier
Uniform Resource Identifier
URITemplate
• http://스프링캠프/발표자/{발표자아이디}
• http://스프링캠프/발표자/kangwoo
Representation
!
!
Client
자원에 대해서 알려줘!!!
!
!
Server
Resources
Request
Response
그 자원은
어쩌고 저쩌고 이다.
Representation
아이디:kangwoo
이름:김강우
취미:잠자기
<발표자>
<아이디>kangwoo</아이디>
<이름>김강우</이름>
<취미>잠자기</취미>
</발표자>
http://스프링캠프/발표자/kangwoo
TEXT Representation XML Representation
Client
!
Server
발표자 Resource
어?
저런건 예전에도
많이 했는데…
응답
HTTP/1.1 200 OK
Content-Length: 100
Content-Type: application/
xml;charset=utf-8
!
<발표자>
<아이디>kangwoo</아이디>
</발표자>
Plain Old XML over HTTP
HTTP Client HTTP Server
Object
Dispatcher
Dispatcher
Object
Server ApplicationClient Application
State Transfer
상태가 뭐지?
상태를 왜 전송하지?
State
발표자의 상태가 안좋습니다.
비 오는 날엔 누군가와
커피를 마시고 싶다
State Transitions
State State
Transition
상태 안좋음 상태 좋음(?)
State Transitions
커피
주문
결제
완료
주문 취소됨
커피
만들기
주문
처리 완료
지불
취소
주문 변경
Resource
Resource Oriented Architecture
자원을 이용한 모델링
커피
주문
결제
완료
주문 취소됨
커피
만들기
주문
처리 완료
지불
취소
주문 변경
자원을 이용한 모델링
주문
Resource
결제
Resource
명사 (noun)
자원을 이용한 모델링
주문
주문 하다.
주문을 확인하다.
주문을 변경하다.
주문을 취소하다.
동사 (verb)
명사? + 동사?
잘 모르겠지만, 일단 만들어보자.
Remote Procedure Call
주문 서비스
주문 하다()
주문을 확인하다()
주문을 변경하다()
주문을 취소하다()
주문 아이템 추가하다()
POST /주문/주문하다
GET /주문/주문확인하다?아이디={주문아이디}
POST /주문/주문변경하다
POST /주문/주문취소하다.
POST /주문/{주문아이디}?action=주문취소
Resource + Identifier
HttpMethod
REST
주문
Resource
GET /주문
GET /주문/{주문아이디}
POST /주문
PUT /주문/{주문아이디}
DELETE /주문/{주문아이디}
주문 하다.
주문을 확인하다.
주문을 변경하다.
주문을 취소하다.
Uniform Interfaces
• Create -> POST
• POST /주문
• Read -> GET
• GET /주문/{주문번호}
• Update -> PUT
• PUT /주문/{주문번호}
• Delete -> DELETE
• DELETE /주문/{주문번호}
GET 을 이용한 자원 보기
GET /주문/1234
200 OK
<주문>
…
</주문>
http://콩다방/주문/1234
고객 콩다방
500 Internal Server Error
404 Not Found
ERRORGET
HTTP Status Code
• 1xx (조건부 응답)
• 2xx (성고)
• 3xx (리다리렉션 완료)
• 4xx (요청 오류)
• 5xx (서버 오류)
출처 : http://ko.wikipedia.org/wiki/HTTP_상태_코드
POST 를 이용한 자원 생성
POST /주문
<주문>
…
</주문>
201 Created
Location http://콩다방/주문/1234
http://콩다방/주문
http://콩다방/주문/1234
고객 콩다방
500 Internal Server Error
400 Bad Request
ERRORCREATE
PUT 을 이용한 자원 수정
PUT /주문/1234
<주문>
…
</주문>
200 OK
OR
204 No Content
http://콩다방/주문/1234
고객 콩다방
500 Internal Server Error
409 Conflict
ERRORUPDATE
404 Not Found
409 Conflict
405 Method Not Allowed
DELETE 를 이용한 자원 삭제
DELETE /주문/1234
200 OK
OR
204 No Content
http://콩다방/주문/1234
고객 콩다방
500 Internal Server Error
405 Method Not Allowed
ERRORDELETE
404 Not Found
그래서 뭐?
State Transitions
커피
주문
결제
완료
주문 취소됨
커피
만들기
주문
처리 완료
지불
취소
주문 변경
커피를 주문하기
POST /주문 HTTP/1.1
Host: 콩다방
Content-Type: application/xml
Content-Length: 1818
!
<주문>
<items>
<item>
<name>아메리카노</name>
<size>제일큰거</size>
</item>
</items>
</주문>
HTTP/1.1 201 Created
Content-Type: application/xml
Content-Length: 1818
Date:몰라
Location: http//콩다방/주문/1234
!
<주문>
<items>
<item>
<name>아메리카노</name>
<size>제일큰거</size>
</item>
</items>
<status>결제 대기중</status>
</주문>
요청 응답
State Transitions
커피
주문
결제
완료
주문 취소됨
커피
만들기
주문
처리 완료
지불
취소
주문 변경
if (status == “결제 대기중”) {
Button 결제버튼 = new Button(“결제”, “http://콩다방/결제/1234”);
Button 변경버튼 = new Button(“변경”, “http://콩다방/변경/1234”, “POST”);
Button 취소버튼 = new Button(“취소”, “http://콩다방/결제/1234”, “DELETE”);
화면.add(결제버튼);
화면.add(변경버튼);
화면.add(취소버튼);
}
앱 개발자의 관점
결제
대기중
결제
주문 변경
주문 취소
Hypermedia
<주문>
<items>
<item>
<name>아메리카노</name>
<size>제일큰거</size>
</item>
</items>
<cost>오백원</cost>
<status>결제 대기중</status>
<links>
<link href=“http://콩다방/결제/1234” rel=“payment”>결제</link>
<link href=“http://콩다방/주문/1234” rel=“update”>주문 변경</link>
<link href=“http://콩다방/주문/1234” rel=“cancel”>주문 취소</link>
</links>
</주문>
응답
주문 상태
결제 대기중 결제
주문 변경
주문 취소
결제 완료
음료 준비중
결제 대기중
HTTP/1.1 200 OK
Content-Type: application/xml
Content-Length: 1818
!
<주문>
<items>
<item>
<name>아메리카노</name>
<size>제일큰거</size>
</item>
</items>
<status>결제 대기중</status>
<links>
<link href=“http://콩다방/결제/1234” rel=“payment”>결제</link>
<link href=“http://콩다방/주문/1234” rel=“update”>주문 변경</link>
<link href=“http://콩다방/주문/1234” rel=“cancel”>주문 취소</link>
</links>
</주문>
요청
응답
GET /주문/1234 HTTP/1.1
Host: 콩다방
결제 완료
HTTP/1.1 200 OK
Content-Type: application/xml
Content-Length: 1818
!
<주문>
<items>
<item>
<name>아메리카노</name>
<size>제일큰거</size>
</item>
</items>
<status>결제 완료</status>
<links>
<link href=“http://콩다방/주문/1234” rel=“update”>주문 변경</link>
<link href=“http://콩다방/주문/1234” rel=“cancel”>주문 취소</link>
</links>
</주문>
요청
응답
GET /주문/1234 HTTP/1.1
Host: 콩다방
음료 준비중
HTTP/1.1 200 OK
Content-Type: application/xml
Content-Length: 1818
!
<주문>
<items>
<item>
<name>아메리카노</name>
<size>제일큰거</size>
</item>
</items>
<status>음료 준비중</status>
</주문>
요청
응답
GET /주문/1234 HTTP/1.1
Host: 콩다방
HATEOAS
Hypermedia As The Engine Of Application State
EntityTag
GET /주문/1234 HTTP/1.1
Host: 콩다방
HTTP/1.1 200 OK
Content-Type: application/vnd.cafe.order+xml
Content-Length: 1818
ETag: “123456789abcdef”
!
<주문>
<items>
<item>
<name>아메리카노</name>
<size>제일큰거</size>
</item>
</items>
<status>결제 대기중</status>
</주문>
요청
응답
EntityTag
GET /주문/1234 HTTP/1.1
Host: 별다방
IF-None-Match: “123456789abcdef”
HTTP/1.1 204 No Content
요청
ETag가 동일할때
HTTP/1.1 200 OK
Content-Type: application/xml
Content-Length: 1818
ETag: “123456789abcdef”
!
<주문>
<items>
<item>
<name>아메리카노</name>
<size>제일큰거</size>
</item>
</items>
ETag가 다를때
EntityTag
PUT /주문/1234 HTTP/1.1
Host: 콩다방
IF-Match: “123456789abcdef”
!
<주문>
…
</주문>
HTTP/1.1 204 No Content
ETag: “123456789abcdef”
요청
응답 (수정 성공)
HTTP/1.1 412 Precondition Failed
응답 (수정 실패)
와플이 먹고 싶어요
주문 변경
POST /주문/1234 HTTP/1.1
Host: 콩다방
!
<주문>
<items>
<item>
<name>아이스크림 와플</name>
<size>제일큰거</size>
</item>
</items>
</주문>
요청
REST
The Programmable Web
Resource
Oriented
Service
Oriented
POX+HTTPREST SOAP
XML-RPC
감사합니다.

Más contenido relacionado

Último

실험 설계의 평가 방법: Custom Design을 중심으로 반응인자 최적화 및 Criteria 해석
실험 설계의 평가 방법: Custom Design을 중심으로 반응인자 최적화 및 Criteria 해석실험 설계의 평가 방법: Custom Design을 중심으로 반응인자 최적화 및 Criteria 해석
실험 설계의 평가 방법: Custom Design을 중심으로 반응인자 최적화 및 Criteria 해석JMP Korea
 
JMP 기능의 확장 및 내재화의 핵심 JMP-Python 소개
JMP 기능의 확장 및 내재화의 핵심 JMP-Python 소개JMP 기능의 확장 및 내재화의 핵심 JMP-Python 소개
JMP 기능의 확장 및 내재화의 핵심 JMP-Python 소개JMP Korea
 
(독서광) 인간이 초대한 대형 참사 - 대형 참사가 일어날 때까지 사람들은 무엇을 하고 있었는가?
(독서광) 인간이 초대한 대형 참사 - 대형 참사가 일어날 때까지 사람들은 무엇을 하고 있었는가?(독서광) 인간이 초대한 대형 참사 - 대형 참사가 일어날 때까지 사람들은 무엇을 하고 있었는가?
(독서광) 인간이 초대한 대형 참사 - 대형 참사가 일어날 때까지 사람들은 무엇을 하고 있었는가?Jay Park
 
데이터 분석 문제 해결을 위한 나의 JMP 활용법
데이터 분석 문제 해결을 위한 나의 JMP 활용법데이터 분석 문제 해결을 위한 나의 JMP 활용법
데이터 분석 문제 해결을 위한 나의 JMP 활용법JMP Korea
 
JMP가 걸어온 여정, 새로운 도약 JMP 18!
JMP가 걸어온 여정, 새로운 도약 JMP 18!JMP가 걸어온 여정, 새로운 도약 JMP 18!
JMP가 걸어온 여정, 새로운 도약 JMP 18!JMP Korea
 
공학 관점에서 바라본 JMP 머신러닝 최적화
공학 관점에서 바라본 JMP 머신러닝 최적화공학 관점에서 바라본 JMP 머신러닝 최적화
공학 관점에서 바라본 JMP 머신러닝 최적화JMP Korea
 
JMP를 활용한 가속열화 분석 사례
JMP를 활용한 가속열화 분석 사례JMP를 활용한 가속열화 분석 사례
JMP를 활용한 가속열화 분석 사례JMP Korea
 
JMP를 활용한 전자/반도체 산업 Yield Enhancement Methodology
JMP를 활용한 전자/반도체 산업 Yield Enhancement MethodologyJMP를 활용한 전자/반도체 산업 Yield Enhancement Methodology
JMP를 활용한 전자/반도체 산업 Yield Enhancement MethodologyJMP Korea
 

Último (8)

실험 설계의 평가 방법: Custom Design을 중심으로 반응인자 최적화 및 Criteria 해석
실험 설계의 평가 방법: Custom Design을 중심으로 반응인자 최적화 및 Criteria 해석실험 설계의 평가 방법: Custom Design을 중심으로 반응인자 최적화 및 Criteria 해석
실험 설계의 평가 방법: Custom Design을 중심으로 반응인자 최적화 및 Criteria 해석
 
JMP 기능의 확장 및 내재화의 핵심 JMP-Python 소개
JMP 기능의 확장 및 내재화의 핵심 JMP-Python 소개JMP 기능의 확장 및 내재화의 핵심 JMP-Python 소개
JMP 기능의 확장 및 내재화의 핵심 JMP-Python 소개
 
(독서광) 인간이 초대한 대형 참사 - 대형 참사가 일어날 때까지 사람들은 무엇을 하고 있었는가?
(독서광) 인간이 초대한 대형 참사 - 대형 참사가 일어날 때까지 사람들은 무엇을 하고 있었는가?(독서광) 인간이 초대한 대형 참사 - 대형 참사가 일어날 때까지 사람들은 무엇을 하고 있었는가?
(독서광) 인간이 초대한 대형 참사 - 대형 참사가 일어날 때까지 사람들은 무엇을 하고 있었는가?
 
데이터 분석 문제 해결을 위한 나의 JMP 활용법
데이터 분석 문제 해결을 위한 나의 JMP 활용법데이터 분석 문제 해결을 위한 나의 JMP 활용법
데이터 분석 문제 해결을 위한 나의 JMP 활용법
 
JMP가 걸어온 여정, 새로운 도약 JMP 18!
JMP가 걸어온 여정, 새로운 도약 JMP 18!JMP가 걸어온 여정, 새로운 도약 JMP 18!
JMP가 걸어온 여정, 새로운 도약 JMP 18!
 
공학 관점에서 바라본 JMP 머신러닝 최적화
공학 관점에서 바라본 JMP 머신러닝 최적화공학 관점에서 바라본 JMP 머신러닝 최적화
공학 관점에서 바라본 JMP 머신러닝 최적화
 
JMP를 활용한 가속열화 분석 사례
JMP를 활용한 가속열화 분석 사례JMP를 활용한 가속열화 분석 사례
JMP를 활용한 가속열화 분석 사례
 
JMP를 활용한 전자/반도체 산업 Yield Enhancement Methodology
JMP를 활용한 전자/반도체 산업 Yield Enhancement MethodologyJMP를 활용한 전자/반도체 산업 Yield Enhancement Methodology
JMP를 활용한 전자/반도체 산업 Yield Enhancement Methodology
 

Destacado

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by HubspotMarius Sescu
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTExpeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 

Destacado (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

REST