오늘 배운 것

 Spring

- RestTemplate

 RestTemplate는 Spring에서 지원하는 클래스로

외부 도메인과의 HTTP 통신을 위한 클래스이며 REST API 호출 이후 응답을 받을 때까지 기다리는 Synchronous 방식으로 운용된다.

우리의 Spring 서버에서 다른 서버로 HTTP request를 편하게 보낼 수 있다...

 

- getForEntity : 설정한 url로 Get request를 보내고 ResponseEntity 형으로 반환받는다.

- postForEntity : 객체를 설정한 url로 POST하여 새 자원을 만들고 ResponseEntity 형으로 반환받는다.

request 자리에 들어가는 Object는 HttpEntity로 캐스팅되거나 생성자 변수로 넘어간다. MessageConverter가 변환할 수 있는 자료형만이 들어가야 한다.

- exchange : RequestEntity에 설정된 request를 이행하고 ResponseEntity 형으로 반환받는다. 메소드 인자에 어떤 http Method를 사용할 건지 설정도 가능하다.

https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/web/client/RestTemplate.html

 

RestTemplate (Spring Framework 6.0.13 API)

postForLocation Create a new resource by POSTing the given object to the URI template, and returns the value of the Location header. This header typically indicates where the new resource is stored. URI Template variables are expanded using the given URI v

docs.spring.io

알고리즘

- 프로그래머스 : 기능개발(Level 2, 큐)

느낀 점

.

 

'TIL' 카테고리의 다른 글

[23.11.17]  (0) 2023.11.17
[23.11.16]  (0) 2023.11.16
[23.11.14]  (2) 2023.11.14
[23.11.13]  (1) 2023.11.13
[23.11.10]  (0) 2023.11.10

+ Recent posts