전체 글

경험을 기술합니다 https://github.com/ImNM
스프링

[스프링] spring 프록시 환경에서 HttpContentCache 적용

두둥 백엔드에서는 에러로그를 cloudWatch 로도 전송하면서, 실시간으로 500번대 알림을 받아보기 위해서 슬랙으로 비동기적으로 에러를 전송하고 있다. 하지만 스프링은 한번 깐 body의 값을 볼 수 없어서 ContentCachingRequestWrapper (Spring Framework 6.0.6 API) handleContentOverflow protected void handleContentOverflow(int contentCacheLimit) Template method for handling a content overflow: specifically, a request body being read that exceeds the specified content cache limit. The..

스프링

[스프링] spring swagger 같은 코드 여러 에러 응답 예시 만들기

[스프링] error code 도메인 별 분리하기 두둥 프로젝트에서는 처리중에 에러가 발생할경우 RuntimeException 을 상속받은 DuDoongException 에서 다시 상속받아서 코드별 에러클래스를 만들고 있다. @Getter @AllArgsConstructor public class DuDoongCodeExceptio devnm.tistory.com 지난 글에서는 error code를 도메인별로 분할하는 작업을 진행했었다. 이번 글에서는 위와 같이 클라이언트들이 에러에대해 보기 쉽도록 나열을 하는 방법을 공유하고자 한다. 목차 1. 문제점 2. 에러 코드를 일일히 적지 않고 어떻게 옮길 수 있을까. 3. 스웨거 타입 분석 4. 적용하기 4.1. 커스텀 어노테이션 생성 4.2. 커스텀 어노테..

스프링

[스프링] 공통 응답 형식 만들기 ResponseBodyAdvice

위처럼 클라이언트와 협의하에 공통응답 형식을 어느정도 맞추고 시작하는 경우가 많다. How to format response before sending in Nest.js? I followed the documentation and was able to add an interceptor for response mapping. I want a consistent json format output for responses. How can I achieve this with interceptor or with something stackoverflow.com nestjs 에서는 공통으로 응답을 처리할 수 있는 부분이 있는데 스프링에서는 CommonResponse 같은 클래스를 만드셔서 사용하시는 분들이 많은것..

스프링

[스프링] error code 도메인 별 분리하기

두둥 프로젝트에서는 처리중에 에러가 발생할경우 RuntimeException 을 상속받은 DuDoongException 에서 다시 상속받아서 코드별 에러클래스를 만들고 있다. @Getter @AllArgsConstructor public class DuDoongCodeException extends RuntimeException { private BaseErrorCode errorCode; public ErrorReason getErrorReason() { return this.errorCode.getErrorReason(); } } 문제는 에러코드를 Enum으로 관리하고 있는데 프로젝트의 크기가 커지면서 한곳에 모아두기엔 너무 복잡았다. 그래서 에러코드를 도메인 별로 분리하는 방법이 있어 공유하고자한다..

ImNM
이찬진 컴퓨터 교실