Added examples for the @RestClientTest article, fixed mail port (#513)
This commit is contained in:
committed by
Grzegorz Piwowarek
parent
3efa23b6b5
commit
cb8f58a9e7
@@ -0,0 +1,32 @@
|
||||
package org.baeldung.client;
|
||||
|
||||
public class Details {
|
||||
|
||||
private String name;
|
||||
|
||||
private String login;
|
||||
|
||||
public Details() {
|
||||
}
|
||||
|
||||
public Details(String name, String login) {
|
||||
this.name = name;
|
||||
this.login = login;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getLogin() {
|
||||
return login;
|
||||
}
|
||||
|
||||
public void setLogin(String login) {
|
||||
this.login = login;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package org.baeldung.client;
|
||||
|
||||
import org.springframework.boot.web.client.RestTemplateBuilder;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
@Service
|
||||
public class DetailsServiceClient {
|
||||
|
||||
private final RestTemplate restTemplate;
|
||||
|
||||
public DetailsServiceClient(RestTemplateBuilder restTemplateBuilder) {
|
||||
restTemplate = restTemplateBuilder.build();
|
||||
}
|
||||
|
||||
public Details getUserDetails(String name) {
|
||||
return restTemplate.getForObject("/{name}/details", Details.class, name);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user