Skip to content

Instantly share code, notes, and snippets.

@numanayhan
Forked from malcommac/networking_8.swift
Created March 30, 2022 12:20
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 numanayhan/2f2e677d3fc62628decffbd8a5af9f37 to your computer and use it in GitHub Desktop.
Save numanayhan/2f2e677d3fc62628decffbd8a5af9f37 to your computer and use it in GitHub Desktop.
func validate(response: HTTPResponse, forRequest request: HTTPRequest) -> HTTPResponseValidatorResult {
if !(200..<300).contains(response.statusCode) {
// invalid response, we want to fail the request with error
throw HTTPError.invalidResponse
}
return .nextValidator // everything is okay, move to next validator
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment