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