-
Notifications
You must be signed in to change notification settings - Fork 116
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refator: Content-type,MultipartForm String값 상수로 정의 #6
- MultiPartForm 프로토콜을MultiPartFormProtocol로 변경 - MultipartForm, contentType enum 구현 및 관련 코드 수정 - 오버로딩된 request 함수명 명확하게 개선 - 들여쓰기 컨벤션 개선
- Loading branch information
1 parent
7bd46d8
commit 513ae69
Showing
7 changed files
with
110 additions
and
38 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// | ||
// ContentType.swift | ||
// OpenMarket | ||
// | ||
// Created by 이호영 on 2022/01/06. | ||
// | ||
|
||
import Foundation | ||
|
||
enum ContentType { | ||
case contentType | ||
case json | ||
case formData(boundary: String) | ||
|
||
var string: String { | ||
switch self { | ||
case .contentType: | ||
return "Content-Type" | ||
case .json: | ||
return "application/json" | ||
case .formData(let boundary): | ||
return "multipart/form-data; boundary=\"\(boundary)\"" | ||
} | ||
} | ||
} |
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,34 @@ | ||
// | ||
// MultipartForm.swift | ||
// OpenMarket | ||
// | ||
// Created by 이호영 on 2022/01/06. | ||
// | ||
|
||
import Foundation | ||
|
||
enum MultipartForm { | ||
case boundary(baseBoundary: String) | ||
case contentDisposition(name: String) | ||
case value(_ value: Any) | ||
case imageContentDisposition(filename: String) | ||
case imageContentType(imageType: String) | ||
case imageValue(data: Data) | ||
|
||
var string: String { | ||
switch self { | ||
case .boundary(let baseBoundary): | ||
return "--\(baseBoundary)\r\n" | ||
case .contentDisposition(let name): | ||
return "Content-Disposition: form-data; name=\"\(name)\"\r\n\r\n" | ||
case .value(let value): | ||
return "\(value)\r\n" | ||
case .imageContentDisposition(let filename): | ||
return "Content-Disposition: form-data; name=\"images[]\"; filename=\"\(filename)\"\r\n" | ||
case .imageContentType(let imageType): | ||
return "Content-Type: \(imageType)\r\n\r\n" | ||
case .imageValue(let data): | ||
return "\(data)\r\n" | ||
} | ||
} | ||
} |
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