Skip to content

Commit 278ccac

Browse files
authored
Merge 0.2.1 to develop (#20)
2 parents 4de63cb + 2da2ead commit 278ccac

3 files changed

Lines changed: 16 additions & 9 deletions

File tree

api-payload/README.md

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,18 @@ Because DefaultResponseWriteUtil and DefaultResponseWriter is already registered
99

1010
```java
1111
@Configuration
12+
@RequiredArgsConstructor
1213
public class ExceptionAdviceConfig {
14+
1315
@Bean
14-
ExceptionAdvice<DefaultResponseErrorReasonDTO> exceptionAdvice(DefaultResponseWriteUtil responseWriteUtil) {
15-
return new ExceptionAdvice<>(new DefaultResponseExceptionAdviceHandler(responseWriteUtil), DefaultResponseErrorReasonDTO.class);
16+
ExceptionAdviceConfigurer exceptionAdviceConfigurer(ExceptionHandlerRegistry exceptionHandlerRegistry) {
17+
ExceptionAdviceConfigurer exceptionAdviceConfigurer = new ExceptionAdviceConfigurer(exceptionHandlerRegistry);
18+
return exceptionAdviceConfigurer
19+
.withDefault()
20+
.enableMethodArgumentNotValidExceptionAdvice(DefaultResponseErrorCode._BAD_REQUEST)
21+
.enableConstraintViolationExceptionAdvice(DefaultResponseErrorCode._BAD_REQUEST)
22+
.enableGlobalExceptionAdvice(DefaultResponseErrorCode._INTERNAL_SERVER_ERROR)
23+
;
1624
}
1725
}
1826
```
@@ -26,10 +34,10 @@ You can use DefaultResponseWriter which is already registered in bean with DI
2634
@RequiredArgsConstructor
2735
public class TestController {
2836

29-
private final ResponseWriter responseWriter;
37+
private final DefaultSuccessResponseWriter responseWriter;
3038

3139
@GetMapping("/success")
32-
public BaseResponse success() {
40+
public DefaultResponse<String> success() {
3341
return responseWriter.ok("success"); // you can use DTO class instead of "success"
3442
}
3543
}
@@ -42,6 +50,5 @@ You can make custom response by implementing BaseResponse, ErrorReasonDTO, Succe
4250

4351
1. Make custom BaseResponse
4452
2. Make custom ErrorReasonDTO, SuccessReasonDTO
45-
3. Make custom ResponseWriteUtil
46-
4. Make custom ExceptionAdviceHandler, ResponseWriter
47-
5. Register your custom Util, Handler, Writer in bean
53+
3. Make custom SuccessResponseWriter, FailureResponseWriter
54+
4. Register your custom Util, Handler, Writer in bean

api-payload/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>org.namul</groupId>
88
<artifactId>beginner</artifactId>
9-
<version>0.2.0</version>
9+
<version>0.2.1</version>
1010
</parent>
1111

1212
<artifactId>api-payload</artifactId>

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
<groupId>org.namul</groupId>
66
<artifactId>beginner</artifactId>
7-
<version>0.2.0</version>
7+
<version>0.2.1</version>
88
<packaging>pom</packaging>
99

1010
<description>

0 commit comments

Comments
 (0)