-
Notifications
You must be signed in to change notification settings - Fork 6
[Feat] #132 - 방문자 플로우 구현 #142
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The head ref may contain hidden characters: "feat/#132-\uBC29\uBB38\uC790-\uD50C\uB85C\uC6B0"
Changes from all commits
56049f0
0485de8
1874d46
670f132
44a2041
b4c750c
c32ef69
b9b07ab
1a70f7a
11c9e2f
7774491
7e49bea
85f8292
3a3a412
d18b938
a62b512
025c401
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,6 +18,16 @@ final class AuthInterceptor: RequestInterceptor { | |
| private init() {} | ||
|
|
||
| func adapt(_ urlRequest: URLRequest, for session: Session, completion: @escaping (Result<URLRequest, Error>) -> Void) { | ||
| var urlRequest = urlRequest | ||
|
|
||
| // 방문자일 경우 | ||
| if UserManager.shared.userType == .visitor && urlRequest.url?.absoluteString.hasPrefix(Config.baseURL) == true { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. urlRequest의 앞부분이 저희 baseurl과 같은지 확인하는 이유가 따로 있나요?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 코스 출발지 검색 api는 카카오 주소 api를 사용하고 있기 때문에 저희 서버 baseUrl과 달라요! 그래서 이 api 호출에서는 방문자를 분기처리할 필요가 없습니다.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 아 그렇쿤요!1 이해했습니다 감사합니다! |
||
| urlRequest.setValue("visitor", forHTTPHeaderField: "accessToken") | ||
| urlRequest.setValue("null", forHTTPHeaderField: "refreshToken") | ||
| completion(.success(urlRequest)) | ||
| return | ||
| } | ||
|
|
||
| guard urlRequest.url?.absoluteString.hasPrefix(Config.baseURL) == true, | ||
| let accessToken = UserManager.shared.accessToken, | ||
| let refreshToken = UserManager.shared.refreshToken | ||
|
|
@@ -26,7 +36,6 @@ final class AuthInterceptor: RequestInterceptor { | |
| return | ||
| } | ||
|
|
||
| var urlRequest = urlRequest | ||
| urlRequest.setValue(accessToken, forHTTPHeaderField: "accessToken") | ||
| urlRequest.setValue(refreshToken, forHTTPHeaderField: "refreshToken") | ||
| print("adator 적용 \(urlRequest.headers)") | ||
|
|
@@ -38,6 +47,7 @@ final class AuthInterceptor: RequestInterceptor { | |
| guard let response = request.task?.response as? HTTPURLResponse, response.statusCode == 401, let pathComponents = request.request?.url?.pathComponents, | ||
| !pathComponents.contains("getNewToken") | ||
| else { | ||
| dump(error) | ||
| completion(.doNotRetryWithError(error)) | ||
| return | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cancleBag은 combine을 써서 할당된 액션을 다 취소해주려고 선언하신 거죠..? 넘 신기한 기능이네요.. 나중에 콤바인 공부하고 다시 살펴볼게요
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Combine은 스트림을 생성하여 비동기적으로 액션을 처리하는 (반응형이라는 명칭이 있음) 프레임워크에요!
cancelBag은 RxSwift처럼 이 스트림을 관리하기 위해 한번 감싼 객체입니다. 원래는
Set<AnyCancellable>로 선언해야해요!클래스의 deInit 시점에 연결해놓은 스트림을 취소하기 위해 선언한 거에요~!
Combine을 공부하기 전에 클로저를 사용한 비동기처리를 먼저 공부하고 도전해보면 좋아요! 매우 편리합니다