Skip to content

Instantly share code, notes, and snippets.

@malcommac
Created March 15, 2022 19:22
Show Gist options
  • Save malcommac/decbd7a0c57218dae2c5b9af6b4af246 to your computer and use it in GitHub Desktop.
Save malcommac/decbd7a0c57218dae2c5b9af6b4af246 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