From 0c29ec6fc0b9e5e4b69757ca763540e0a8280361 Mon Sep 17 00:00:00 2001 From: Gyoungmin Kim Date: Mon, 4 Nov 2024 13:49:06 +0900 Subject: [PATCH] refactor: change authorization header getting logic for recap api --- photo-service/src/main/java/kr/mafoo/photo/api/RecapApi.java | 4 ++-- .../main/java/kr/mafoo/photo/controller/RecapController.java | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/photo-service/src/main/java/kr/mafoo/photo/api/RecapApi.java b/photo-service/src/main/java/kr/mafoo/photo/api/RecapApi.java index a418448..70326e5 100644 --- a/photo-service/src/main/java/kr/mafoo/photo/api/RecapApi.java +++ b/photo-service/src/main/java/kr/mafoo/photo/api/RecapApi.java @@ -7,6 +7,7 @@ import kr.mafoo.photo.annotation.RequestMemberId; import kr.mafoo.photo.controller.dto.request.RecapCreateRequest; import kr.mafoo.photo.controller.dto.response.RecapResponse; +import org.springframework.http.server.reactive.ServerHttpRequest; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import reactor.core.publisher.Mono; @@ -29,8 +30,7 @@ Mono createRecap( @RequestParam(required = false) String sort, - @RequestHeader("Authorization") - String authorizationToken + ServerHttpRequest serverHttpRequest ); } diff --git a/photo-service/src/main/java/kr/mafoo/photo/controller/RecapController.java b/photo-service/src/main/java/kr/mafoo/photo/controller/RecapController.java index aec3718..19f1866 100644 --- a/photo-service/src/main/java/kr/mafoo/photo/controller/RecapController.java +++ b/photo-service/src/main/java/kr/mafoo/photo/controller/RecapController.java @@ -5,6 +5,7 @@ import kr.mafoo.photo.controller.dto.response.RecapResponse; import kr.mafoo.photo.service.RecapService; import lombok.RequiredArgsConstructor; +import org.springframework.http.server.reactive.ServerHttpRequest; import org.springframework.web.bind.annotation.RestController; import reactor.core.publisher.Mono; @@ -19,8 +20,10 @@ public Mono createRecap( String memberId, RecapCreateRequest request, String sort, - String authorizationToken + ServerHttpRequest serverHttpRequest ) { + String authorizationToken = serverHttpRequest.getHeaders().getFirst("Authorization"); + return recapService.createRecap(request.albumId(), memberId, sort, authorizationToken) .map(RecapResponse::fromString); }