Skip to content

Instantly share code, notes, and snippets.

@deepakmehra10
Created July 1, 2019 07:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save deepakmehra10/9a053a744f32a4a1e0c2b27bf5615b69 to your computer and use it in GitHub Desktop.
Save deepakmehra10/9a053a744f32a4a1e0c2b27bf5615b69 to your computer and use it in GitHub Desktop.
@Service
public class ContentServiceImpl implements ContentService {
private static final Logger LOGGER = Logger.getLogger(ContentServiceImpl.class.getName());
private final WebClient webClient;
public ContentServiceImpl(@Value("${content-service}") String baseURL) {
this.webClient = WebClient.builder().baseUrl(baseURL)
.defaultHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_UTF8_VALUE)
.filter(logRequest())
.build();
}
@Override
public Mono<Post> getPost(int id) {
return webClient.get().uri("posts/{id}", id).retrieve().bodyToMono(Post.class);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment