Skip to content

Instantly share code, notes, and snippets.

@ekscrypto
Created February 21, 2019 02:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ekscrypto/6d0c774d8736ca4cf4d833779a3e60df to your computer and use it in GitHub Desktop.
Save ekscrypto/6d0c774d8736ca4cf4d833779a3e60df to your computer and use it in GitHub Desktop.
extension APIRequest {
public static func urlRequest(from request: APIEndpoint) -> URLRequest? {
let endpoint = request.endpoint()
guard let endpointUrl = URL(string: "\(AppSettings.shared.serverBaseAddress)\(endpoint)") else {
return nil
}
var endpointRequest = URLRequest(url: endpointUrl)
endpointRequest.addValue("application/json", forHTTPHeaderField: "Accept")
return endpointRequest
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment