-
[REST]Springboot 2019. 12. 6. 15:28
REST : 분산하이퍼미디어 시스템에서 사용하는 통신 네트워크 아키텍쳐
RESTful : REST 구현 원칙을 지키면서 REST 아키텍쳐를 만드는 것
- client와 server의 분리
- stateless. server는 client 상태정보를 저장안함. 요청만 처리함.
- cacheable. client request를 캐시한다.
- layered system. server는 로드 밸런싱, 공유 캐시, 중개서버(프록시,게이트웨이)를 사용해 확성있는 시스템 구성가능
- uniform interface. 균일하고 통일된 URI interface 제공
- code on demand. client는 server에 코드를 받아 일시적 기능확장 가능(선택사항)
#uniform interface
자원식별 : http://localhost:8080/resource/1
메시지로 리소스 조작 : http://localhost:8080/resource/1 content-type:application/json
자기 서술적인 메세지 : GET http://localhost:8080/resource/1 content-type:application/json
HETAOAS : application state에 대한 엔진으로서의 하이퍼미디어.. 뭔 소리야?
** URI 명명규칙
복수형 명사
동사 대신 HTTP Method (Get,Post,Put,Delete)
@RepositoryRestResource(collectionResourceRel = "persons", path = "people")
collectionResourceRel --> "_embedded" : { "persons" : [ ] }
curl -i -X POST -H "Content-Type:application/json" -d "{\"firstName\": \"Frodo\", \"lastName\":\"Baggins\"}" http://localhost:8080/people
- -i: Ensures you can see the response message including the headers.
- -X POST: Signals this a POST used to create a new entry.
- -H "Content-Type:application/json": Sets the content type so the application knows the payload contains a JSON object.
- -d "{ //... }": Is the data being sent.
curl -X PUT -H "Content-Type:application/json" -d "{\"firstName\": \"Bilbo Jr.\"}" http://localhost:8080/people/1 "firstName" : "Bilbo", "lastName" : "Baggins", curl -X PUT -H "Content-Type:application/json" -d "{\"firstName\": \"Bilbo Jr.\"}" http://localhost:8080/people/1 "firstName" : "Bilbo Jr.", "lastName" : null,
PUT replaces an entire record. Fields not supplied are replaced with null.
curl -X PATCH -H "Content-Type:application/json" -d "{\"lastName\": \"Naver\"}" http://localhost:8080/people/1 "firstName" : "Bilbo Jr.", "lastName" : "Naver",
PATCH update a subset of items.
curl -X DELETE http://localhost:8080/people/1
'Springboot' 카테고리의 다른 글
[Batch] (0) 2020.06.15 [H2] (0) 2019.12.20 curl Unexpected character (''' (code 39)) (0) 2019.12.06 [Data] gradle+mysql+jpa (0) 2019.12.05 [Lombok] 이클립스 적용안됨 (0) 2019.10.24