Skip to content

Instantly share code, notes, and snippets.

@harikrishnan83
Created February 25, 2020 12:45
Show Gist options
  • Save harikrishnan83/2f9c4cda61e7eadef1bf89b785251f47 to your computer and use it in GitHub Desktop.
Save harikrishnan83/2f9c4cda61e7eadef1bf89b785251f47 to your computer and use it in GitHub Desktop.
class HttpRequest(private val url: String, private val method: HttpMethod, private val body: String) {
fun matches(anotherRequest: HttpRequest): Result {
if (this.url != anotherRequest.url)
return Failure("URL did not match. ${this.url} not equal to ${anotherRequest.url}")
if (this.method != anotherRequest.method)
return Failure("Method did not match. ${this.method} not equal to ${anotherRequest.method}")
if (this.body != anotherRequest.body)
return Failure("Body did not match. ${this.body} not equal to ${anotherRequest.body}")
return Success("everything matches")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment