-
Notifications
You must be signed in to change notification settings - Fork 1
[FEAT] API 버저닝을 위한 ACTargetType 구현, 리뷰 API 수정 (#242) #250
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
Conversation
cirtuare
left a comment
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.
리뷰 확인 부탁드립니다 ~~!
| // | ||
| // ApiVersionProtocol.swift | ||
| // ACON-iOS | ||
| // | ||
| // Created by 김유림 on 8/5/25. | ||
| // | ||
|
|
||
| import Foundation | ||
|
|
||
| import Moya | ||
|
|
||
| // MARK: - Protocol | ||
|
|
||
| protocol ACTargetType: TargetType { | ||
|
|
||
| var apiVersion: ApiVersionType { get } | ||
|
|
||
| } | ||
|
|
||
|
|
||
| // MARK: - Extension | ||
|
|
||
| extension ACTargetType { | ||
|
|
||
| var baseURL: URL { | ||
| guard let urlString = Bundle.main.object(forInfoDictionaryKey: Config.Keys.Plist.baseURL) as? String, | ||
| let url = URL(string: urlString) else { | ||
| fatalError("💢💢 BASE_URL이 없음 💢💢") | ||
| } | ||
| return url | ||
| } | ||
|
|
||
| /// API 버전 기본값 (.v1). 필요 시 각 TargetType에서 오버라이드하여 변경 가능. | ||
| var apiVersion: ApiVersionType { | ||
| return .v1 | ||
| } | ||
|
|
||
| var utilPath: String { | ||
| return apiVersion.utilPath | ||
| } | ||
|
|
||
| } |
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.
🐿️🐿️🐿️
굳이 ACTargetType을 따로 만드신 이유가 있나요?? 기존 TargetType+에서 apiVersion을 선언했어도 필요한 경우만 오버라이딩하면 돼서 불필요하다고 생각합니다..!
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.
b1e8428 에서 처음에 그렇게 구현했었는데,
코드를 호출해보니
protocol extension의 기본 구현은 오버라이딩이 안 되며,
가능하게 하려면 따로 프로토콜을 구현해야함을 알게 되었습니다. (참고)
오버라이딩을 포기하고 각각의 TargetType 내에서
아래처럼 손수 utilPath를 구현하자니 확장성이 너무 떨어져서,
위 코드처럼 ACTargetType 프로토콜을 만들게 되었습니다
var apiVersion: ApiVersion {
switch self {
case .getSearchSuggestion,
return .v2
default:
return .v2
}
}
var utilPath: String {
return apiVersion.path
}
var path: String {
switch self {
case .getSearchSuggestion:
return utilPath + "search-suggestions"
....
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.
확인했습니다 !!!!
🐿️ Pull Requests
🪵 작업 브랜치
🥔 작업 내용
1. API 버저닝을 위해
ACTargetType을 구현했습니다. (Moya의 TargetType 프로토콜 상속)우리팀 컨벤션상으로는
ACTargetTypeProtocol식으로 네이밍해야하지만,길이가 길고, Moya의 TargetType이라는 느낌이 약해지는 것 같아 -protocol을 생략했습니다.
혹시
ACTargetTypeProtocol으로 하는 게 좋겠다고 생각하시면 말씀해주세요!Code
Usage
2. 리뷰 API 변경사항을 반영했습니다.
📸 스크린샷
💥 To be sure
🌰 Resolve issue