Created
September 28, 2016 04:48
-
-
Save yellowred/7757104e00c01076b5a85548c7bdcebf to your computer and use it in GitHub Desktop.
Alamofire custom parameter encoder
This file contains hidden or 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
extension String: ParameterEncoding { | |
public func encode(_ urlRequest: URLRequestConvertible, with parameters: Parameters?) throws -> URLRequest { | |
var request = try urlRequest.asURLRequest() | |
request.httpBody = data(using: .utf8, allowLossyConversion: false) | |
request.setValue("application/json", forHTTPHeaderField: "Content-Type") | |
return request | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment