diff options
author | Adam Warski <adam@warski.org> | 2018-03-28 13:25:29 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-03-28 13:25:29 +0200 |
commit | 3d8b615c89c276ff1c2db349688079a6d9f5405c (patch) | |
tree | bd4e4f30e743ecdc873d7614a74c9329be6b5e99 /docs/testing.rst | |
parent | 9081387e3f2134c6cf3e321f64b833f7a0b911a8 (diff) | |
parent | 09e2a6f1e998bc7f5f0cd2a27dd8c10a37df4602 (diff) | |
download | sttp-3d8b615c89c276ff1c2db349688079a6d9f5405c.tar.gz sttp-3d8b615c89c276ff1c2db349688079a6d9f5405c.tar.bz2 sttp-3d8b615c89c276ff1c2db349688079a6d9f5405c.zip |
Merge pull request #75 from softwaremill/stub-response-from-request
Added overloaded thenRespondWrapped which can return response monad but takes request as parameter
Diffstat (limited to 'docs/testing.rst')
-rw-r--r-- | docs/testing.rst | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/docs/testing.rst b/docs/testing.rst index 9afcd0e..2a6d37b 100644 --- a/docs/testing.rst +++ b/docs/testing.rst @@ -60,6 +60,16 @@ Another way to specify the behaviour is passing response wrapped in the result m val responseFuture = sttp.get(uri"http://example.org").send() // responseFuture will complete after 5 seconds with "OK" response +The returned response may also depend on the request: :: + + implicit val testingBackend = SttpBackendStub(HttpURLConnectionBackend()).whenAnyRequest + .thenRespondWrapped(req => + Response(Right("OK, got request sent to ${req.uri.host}"), 200, "", Nil, Nil) + ) + + val response = sttp.get(uri"http://example.org").send() + // response.body will be Right("OK, got request sent to example.org") + Simulating exceptions --------------------- |