-
Notifications
You must be signed in to change notification settings - Fork 3
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
[Feat] #14 - 네트워크 레이어 구현 및 클린아키텍쳐 예시코드 작성 #25
Merged
L-j-h-c
merged 7 commits into
TeamRecorDream:develop
from
L-j-h-c:feature/#14-NetworkModule
Oct 23, 2022
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
7ddc47e
[Feat] #14 - 네트워크 모듈 기본 세팅 구현
L-j-h-c 4c40e09
[Fix] #14 - 접근제한자 변경
L-j-h-c 72e228d
[Fix] #14 - 레코드림에 맞게 메서드 개선
L-j-h-c eac5165
[Feat] #14 - DreamWrite 기준 클린 아키텍쳐 예시코드 작성
L-j-h-c 4e6a362
[Feat] #14 - 접근제한자 수정 및 RequestEntity 생성
L-j-h-c d8ee675
[Feat] #14 - DreamWrite Presentation Layer 바인딩
L-j-h-c 6a56ba1
[Fix] #14 - 코드리뷰 반영
L-j-h-c File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 0 additions & 13 deletions
13
RecorDream-iOS/Projects/Data/Sources/Network/DTO/DreamWriteDTO.swift
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ | |
// | ||
|
||
import Domain | ||
import RD_Network | ||
|
||
import RxSwift | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
8 changes: 0 additions & 8 deletions
8
RecorDream-iOS/Projects/Modules/RD-Network/Sources/API/Sample.swift
This file was deleted.
Oops, something went wrong.
33 changes: 33 additions & 0 deletions
33
RecorDream-iOS/Projects/Modules/RD-Network/Sources/Environment/GeneralResponse.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// | ||
// GeneralResponse.swift | ||
// RD-NetworkTests | ||
// | ||
// Created by Junho Lee on 2022/10/14. | ||
// Copyright © 2022 RecorDream. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
struct GeneralResponse<T> { | ||
let success: Bool | ||
let status: Int | ||
let message: String? | ||
let data: T? | ||
|
||
enum CodingKeys: String, CodingKey { | ||
case success | ||
case status | ||
case message | ||
case data | ||
} | ||
} | ||
|
||
extension GeneralResponse: Decodable where T: Decodable { | ||
init(from decoder: Decoder) throws { | ||
let container = try decoder.container(keyedBy: CodingKeys.self) | ||
success = try container.decode(Bool.self, forKey: .success) | ||
status = try container.decode(Int.self, forKey: .status) | ||
message = try? container.decode(String.self, forKey: .message) | ||
data = try? container.decode(T.self, forKey: .data) | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
RecorDream-iOS/Projects/Modules/RD-Network/Sources/Environment/HeaderType.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// | ||
// HeaderType.swift | ||
// RD-NetworkTests | ||
// | ||
// Created by Junho Lee on 2022/10/14. | ||
// Copyright © 2022 RecorDream. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
public enum HeaderType { | ||
case `default` | ||
case withToken | ||
case multiPart | ||
case multiPartWithToken | ||
case reissuance | ||
} | ||
|
||
enum HTTPHeaderField: String { | ||
case contentType = "Content-Type" | ||
case authorization = "Authorization" | ||
|
||
case access | ||
case refresh = "refreshtoken" | ||
} | ||
|
||
enum HeaderContent: String { | ||
case json = "application/json" | ||
case multiPart = "multipart/form-data" | ||
case accessTokenSerial = "액세스 토큰 스트링" | ||
case refreshTokenSerial = "리프레시 토큰 스트링" | ||
} |
17 changes: 17 additions & 0 deletions
17
RecorDream-iOS/Projects/Modules/RD-Network/Sources/Environment/NetworkResult.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// | ||
// NetworkResult.swift | ||
// RD-NetworkTests | ||
// | ||
// Created by Junho Lee on 2022/10/14. | ||
// Copyright © 2022 RecorDream. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
enum NetworkResult<T> { | ||
case success(T) | ||
case requestErr(T) | ||
case pathErr | ||
case serverErr | ||
case networkFail | ||
} |
33 changes: 33 additions & 0 deletions
33
RecorDream-iOS/Projects/Modules/RD-Network/Sources/Foundation/AFManager.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// | ||
// AFManager.swift | ||
// RD-NetworkTests | ||
// | ||
// Created by Junho Lee on 2022/10/14. | ||
// Copyright © 2022 RecorDream. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
import Alamofire | ||
|
||
class Managers { | ||
|
||
static let `default`: Session = { | ||
var session = AF | ||
let configuration = URLSessionConfiguration.af.default | ||
configuration.timeoutIntervalForRequest = NetworkEnvironment.requestTimeOut | ||
configuration.timeoutIntervalForResource = NetworkEnvironment.resourceTimeOut | ||
let eventLogger = APIEventLogger() | ||
let interceptor = AlamoInterceptor() | ||
session = Session(configuration: configuration, interceptor: interceptor, eventMonitors: [eventLogger]) | ||
return session | ||
}() | ||
|
||
private init() { } | ||
} | ||
|
||
public extension Session { | ||
func uploadMultipart(target: BaseRouter) -> UploadRequest { | ||
return self.upload(multipartFormData: target.multipart, with: target) | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
오 reissuance는 언제 쓰이는 헤더타입인가요 ??!
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.
@Suyeon9911 토큰 재발급의 경우에 사용하는 케이스입니다! BaseService에서 헤더를 분기처리하는 곳을 보시면 reissuance의 경우에만 access와 refresh token 모두를 헤더에 실어서 보내주는 것을 확인할 수 있습니다. 저번 프로젝트에서 이런 방식으로 재발급을 처리했는데 레코드림의 경우에는 다른 방식(바디에 토큰을 보내는)을 사용할 수도 있을 것 같습니다. 논의하기 나름일듯~~