Skip to content
This repository has been archived by the owner on Jun 1, 2024. It is now read-only.

Commit

Permalink
Fixes filter to handle only beagle requests
Browse files Browse the repository at this point in the history
Signed-off-by: Hernand Azevedo <[email protected]>
  • Loading branch information
hernandazevedozup committed Sep 26, 2022
1 parent 9b7da7b commit 309b056
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,16 @@ class BeaglePlatformFilter(private val objectMapper: ObjectMapper) : Filter {
response: ServletResponse?,
chain: FilterChain?
) {
val isServletRequestResponse = request is HttpServletRequest && response is HttpServletResponse
val httpServletResponse = response as? HttpServletResponse
val httpServletRequest = request as? HttpServletRequest
val platformHeader = httpServletRequest?.getHeader(BeaglePlatformUtil.BEAGLE_PLATFORM_HEADER)
val isServletRequestResponse = request is HttpServletRequest && response is HttpServletResponse
val platformHeader =
if (isServletRequestResponse)
httpServletRequest?.getHeader(BeaglePlatformUtil.BEAGLE_PLATFORM_HEADER)
else null

if (chain != null && isServletRequestResponse && platformHeader != null) {
request.setAttribute(BeaglePlatformUtil.BEAGLE_PLATFORM_HEADER, platformHeader)
request?.setAttribute(BeaglePlatformUtil.BEAGLE_PLATFORM_HEADER, platformHeader)
val responseWrapper = ContentCachingResponseWrapper(httpServletResponse)
chain.doFilter(request, responseWrapper)
treatResponse(responseWrapper, platformHeader)
Expand Down

0 comments on commit 309b056

Please sign in to comment.