회원가입 시나리오로 예를들면
사용자가 입력한 아이디를
'아이디 중복확인' 버튼을 통해 중복체크 API 호출
이때 아이디가 중복된 상태라면 Response로 어떠한 상태 코드를 반환해야 할까?
기존에는 409 Conflict(원본과 현재 요청이 충돌)를 사용했지만
422 Unprocessable Entity(요청은 정확하게 이루어졌지만 처리할 수 없음)가 더 적절한 상태코드인것 같다.
출처 : https://stackoverflow.com/questions/25015592/whats-the-best-return-code-for-unique-violations
What's the best return code for "@unique" violations?
I'm working on a RESTful web API with a Hibernate powered back-end. So far, we've mapped a few error codes. For instance, when @Version validation fails, our API returns HTTP error code 409. Now, we
stackoverflow.com
출처 : https://developer.mozilla.org/en-US/docs/Web/HTTP/Status#client_error_responses
HTTP response status codes - HTTP | MDN
HTTP response status codes indicate whether a specific HTTP request has been successfully completed. Responses are grouped in five classes:
developer.mozilla.org
'Spring Boot' 카테고리의 다른 글
[Spring] 사용자 중복 로그인 막는 방법 (0) | 2023.03.16 |
---|---|
[Spring] IntelliJ RMI TCP Connection 에러 (0) | 2023.03.14 |
[Spring] 2개 이상의 유니크 키를 분리하여 예외처리 하기 (0) | 2023.01.31 |
[Spring] @Transactional 롤백 기능 이용하기 (0) | 2023.01.18 |
[JPA] @Entity @Table 차이점 (0) | 2022.09.14 |