Created
February 8, 2018 12:52
-
-
Save PauloLeon/1a8570943f398f37fdbfa48ab2351326 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
func asURLRequest() throws -> URLRequest { | |
let url: URL | |
if path == "estimates" || path == "users"{ | |
url = try Router.routeResults.asURL() | |
} else { | |
url = try Router.routeGoogle.asURL() | |
} | |
var urlRequest = URLRequest(url: url.appendingPathComponent(path)) | |
urlRequest.httpMethod = method.rawValue | |
if hearders != ""{ | |
//caso o header não seja vazio, ele envia o parametro do header com o field Api-Key | |
urlRequest.setValue(hearders, forHTTPHeaderField: "Api-Key") | |
} | |
if let parameters = parameters { | |
urlRequest = try URLEncoding.default.encode(urlRequest, with: parameters) | |
} | |
print("*** \(urlRequest)") | |
return urlRequest | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment