Skip to content

Commit

Permalink
feat : POST 되는 객체에 대해 Request body Validation을 진행
Browse files Browse the repository at this point in the history
  • Loading branch information
Yangdaehan committed May 2, 2024
1 parent 62a4ffd commit e42cb1e
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.sopt.spring.controller;

import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.sopt.spring.common.dto.SuccessStatusResponse;
import org.sopt.spring.service.PostService;
Expand All @@ -15,14 +16,14 @@
public class PostController {

private final PostService postService;

@PostMapping("/posts")
public ResponseEntity<SuccessStatusResponse> createPost(
@RequestHeader Long blogId,
@RequestBody PostCreateRequest postCreateRequest) {
@Valid @RequestBody PostCreateRequest postCreateRequest) {
return ResponseEntity.status(HttpStatus.CREATED).header(
"Location",
postService.create(blogId, postCreateRequest))
.body(SuccessStatusResponse.of(SuccessMessage.POST_CREATE_SUCCESS));
}
}

0 comments on commit e42cb1e

Please sign in to comment.