Skip to content

Instantly share code, notes, and snippets.

@jemai
Last active March 13, 2019 16:40
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 jemai/2aaa8e8a09a1a4c550ad2fb8b6a6ef59 to your computer and use it in GitHub Desktop.
Save jemai/2aaa8e8a09a1a4c550ad2fb8b6a6ef59 to your computer and use it in GitHub Desktop.
struct service: Requester {}
func doSomething() {
// we are going to call this test api
let request = HTTPRequest(url: "http://ip.jsontest.com/")
service.execute(ofType: ResponseMapper.self, request: request) { (result) in
switch result {
case .failure(let error):
print(error)
case .success(let object):
print(object)
}
}
}
// the response type
struct ResponseMapper: Codable {
let ip: String
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment