-
-
Save Juanpe/721a2198bed905becd0cc859628895e4 to your computer and use it in GitHub Desktop.
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
class URLRequestBuilder { | |
var adapters: [RequestAdapter] = [] | |
// ...rest of properties... | |
@discardableResult | |
func add(adapter: RequestAdapter?) -> URLRequestBuilder { | |
guard let adapter = adapter else { return self } | |
adapters.append(adapter) | |
return self | |
} | |
// ...rest of sets... | |
func build() throws -> URLRequest { | |
do { | |
try adapters.forEach { | |
urlRequest = try $0.adapt(urlRequest) | |
} | |
// rest of code... | |
return urlRequest | |
} catch { | |
throw APIError.requestBuilderFailed | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment