Skip to content

Commit

Permalink
Refactor : Etag get 요청에 관한 전체 설정으로 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
byeolhaha committed Dec 15, 2023
1 parent 60666e2 commit c8eb0dd
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ public ResponseEntity<AcademyGetResponse> getAcademy(
AcademyDetailFacadeResult detailAcademy = academyFacade.getDetailAcademy(AcademyDetailFacadeParam.of(memberId, academyId));

return ResponseEntity.status(HttpStatus.OK)
.cacheControl(CacheControl.noCache())
.body(AcademyGetResponse.from(detailAcademy));
}

Expand All @@ -65,7 +64,6 @@ public ResponseEntity<AcademiesByLocationWithScrollResponses> findByLocationWith
AcademyByLocationWithScrollRequest.to(request, memberId));

return ResponseEntity.status(HttpStatus.OK)
.cacheControl(CacheControl.noCache())
.body(AcademiesByLocationWithScrollResponses.from(response));
}

Expand All @@ -79,7 +77,6 @@ public ResponseEntity<AcademiesByNameResponses> findByName(
AcademiesByNameRequest.to(request));

return ResponseEntity.status(HttpStatus.OK)
.cacheControl(CacheControl.noCache())
.body(AcademiesByNameResponses.from(academiesByNameResults));
}

Expand All @@ -94,7 +91,6 @@ public ResponseEntity<AcademiesFilterWithScrollResponses> filterAcademies(
AcademyFilterWithScrollRequest.to(request), memberId);

return ResponseEntity.status(HttpStatus.OK)
.cacheControl(CacheControl.noCache())
.body(AcademiesFilterWithScrollResponses.from(academiesFilterWithScrollResults));
}

Expand All @@ -108,7 +104,6 @@ public ResponseEntity<LessonInfoToCreateDashboardResponses> getLessonInfosToCrea
academyId);

return ResponseEntity.status(HttpStatus.OK)
.cacheControl(CacheControl.noCache())
.body(LessonInfoToCreateDashboardResponses.from(lessonsInfoAboutAcademy));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ public ResponseEntity<ChildrenFindResponse> findChildren(@MemberId Long memberId

return ResponseEntity
.status(HttpStatus.OK)
.cacheControl(CacheControl.noCache())
.body(ChildrenFindResponse.from(childrenByMemberIdAndDateTime));
}

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package org.guzzing.studayserver.global.config;

import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.filter.ShallowEtagHeaderFilter;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebConfig implements WebMvcConfigurer {
@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(new HandlerInterceptor() {
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
if(request.getMethod().equals("GET")) {
response.setHeader("Cache-Control","no-cache");
}
return HandlerInterceptor.super.preHandle(request, response, handler);
}
});
}

@Bean
public ShallowEtagHeaderFilter shallowEtagHeaderFilter() {
return new ShallowEtagHeaderFilter();
}

}

0 comments on commit c8eb0dd

Please sign in to comment.