Add route to fetch post source.
This commit is contained in:
@@ -53,12 +53,19 @@ public class PostController {
|
||||
@GetMapping("/{postKey}")
|
||||
public PostDTO getByKey(@PathVariable("postKey") final String pPostKey,
|
||||
final HttpServletResponse response) {
|
||||
final PostDTO result = getByKeyAndSource(pPostKey, response);
|
||||
result.setText(parserService.parse(result.getText()));
|
||||
return result;
|
||||
}
|
||||
|
||||
@GetMapping("/{postKey}/source")
|
||||
public PostDTO getByKeyAndSource(@PathVariable("postKey")final String pPostKey,
|
||||
final HttpServletResponse response) {
|
||||
PostDTO result = null;
|
||||
|
||||
final Optional<Post> post = postRepository.getByKey(pPostKey);
|
||||
if(post.isPresent()) {
|
||||
result = new PostDTO(post.get());
|
||||
result.setText(parserService.parse(result.getText()));
|
||||
} else {
|
||||
response.setStatus(HttpServletResponse.SC_NOT_FOUND);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user