Skip to content

Instantly share code, notes, and snippets.

@Plnda
Last active June 21, 2020 13:58
Show Gist options
  • Save Plnda/dea929b667fdcae7fdf9eaf4048a6227 to your computer and use it in GitHub Desktop.
Save Plnda/dea929b667fdcae7fdf9eaf4048a6227 to your computer and use it in GitHub Desktop.
import Foundation
protocol NetworkRoute {
var path: String { get }
var method: NetworkMethod { get }
var headers: [String: String]? { get }
}
extension NetworkRoute {
var headers: [String : String]? {
return nil
}
func create(for enviroment: NetworkEnviroment) -> URLRequest {
var request = URLRequest(url: URL(string: enviroment.rawValue + path)!)
request.allHTTPHeaderFields = headers
request.httpMethod = method.rawValue.uppercased()
return request
}
}
@elven4u
Copy link

elven4u commented Jun 21, 2020

Line16: NetworkEnviroment
should be
NetworkEnvironment?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment