본문 바로가기

전체 글218

Interceptor에서 예외처리 구현 exception/패키지 안에 .. Interceptor은 api요청들어올때 처리해주는 가장 앞단이기 때문에 잘못된 값일때 예외처리를 따로 해주어야한다. 각각 AccessDeniedException / RuntimeException / Exception 로 비교하여 에러 메세지가 떨어지게 만들었다. RuntimeException.java @Getter public class InterceptorException extends RuntimeException { private InterceptorExceptionEnum error; public InterceptorException(InterceptorExceptionEnum e) { super(e.getMessage()); this.error = e; } .. 2021. 7. 4.
ES6 이터러블 /이터레이터, 리스트 순회 리스트 순회 기존 for(var i =0;i< str.length;i++){ ... } es6 for(const a of list){ ... } 간결하게 변경 되었음 이터러블/이터레이터 Array , Set, Map const arr = [1,2,3]; for(const a of arr){ } const set = new Set([1,2,3]); for(const a of set){ } const map = new Map(['a',1], ['b',2] , ['c',3]); for(const a of map){ } array 는 arr[0] , arr[1] 이렇게 해서 값을 찾을 수 있지만 Set과 Map은 불가능함 어떻게 for of문에서 동작이 되는가? Symbol.iterator es6에 추가된 sy.. 2021. 7. 3.
로그인 세션관리 구현(Interceptor, jwt 토큰) 잊지 않기위해 저장저장 jwt 토큰 발급해 세션 저장하는 로직 구현 세션은 redis에 저장한다. 세션 하루 만료 기준! 세션이 발급되면 jwt토큰값은 모든 API를 헤더값에 넣어서 보내준다. 만료되면 다시 발급요청! 하기 AuthInterceptor.java @Component @Slf4j public class AuthInterceptor implements HandlerInterceptor { @Autowired private JwtUtil jwtUtil; @Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { String jw.. 2021. 7. 3.
CORS 설정 백엔드에서 CORS설정하기 @Configuration public class WebAppConfiguration implements WebMvcConfigurer{ private AuthInterceptor myInterceptor; @Autowired public WebAppConfiguration(AuthInterceptor myInterceptor){ this.myInterceptor = myInterceptor; } @Override public void addInterceptors(InterceptorRegistry registry) { registry.addInterceptor(myInterceptor) .addPathPatterns("/**"); } @Override public void a.. 2021. 7. 2.
반응형