Skip to content

Commit 1557c5f

Browse files
committed
Remove specialize response-mapping request functions
1 parent f28dcea commit 1557c5f

File tree

4 files changed

+5
-18
lines changed

4 files changed

+5
-18
lines changed

core/src/main/scala/sttp/client4/request.scala

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import sttp.attributes.AttributeMap
2828
trait GenericRequest[+T, -R] extends RequestBuilder[GenericRequest[T, R]] with RequestMetadata {
2929
def body: GenericRequestBody[R]
3030
def response: ResponseAsDelegate[T, R]
31+
3132
def mapResponse[T2](f: T => T2): GenericRequest[T2, R]
3233

3334
def toCurl: String = ToCurlConverter(this)
@@ -168,19 +169,6 @@ case class Request[T](
168169
def send(backend: SyncBackend): Response[T] = backend.send(this)
169170
}
170171

171-
object Request {
172-
implicit class RichRequestTEither[A, B](r: Request[Either[A, B]]) {
173-
def mapResponseRight[B2](f: B => B2): Request[Either[A, B2]] = r.copy(response = r.response.mapRight(f))
174-
def responseGetRight: Request[B] = r.copy(response = r.response.orFail)
175-
}
176-
177-
implicit class RichRequestTEitherResponseException[HE, DE, B](
178-
r: Request[Either[ResponseException[HE, DE], B]]
179-
) {
180-
def responseGetEither: Request[Either[HE, B]] = r.copy(response = r.response.orFailDeserialization)
181-
}
182-
}
183-
184172
//
185173

186174
/** Describes an HTTP request, along with a description of how the response body should be handled. Either the request

core/src/test/scala/sttp/client4/testing/BackendStubTests.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,7 @@ class BackendStubTests extends AnyFlatSpec with Matchers with ScalaFutures {
144144

145145
val result = basicRequest
146146
.get(uri"http://example.org")
147-
.mapResponseRight(_.toInt)
148-
.mapResponseRight(_ * 2)
147+
.response(asString.mapRight((_: String).toInt).mapRight((_: Int) * 2))
149148
.send(backend)
150149

151150
result.body should be(Right(20))

core/src/test/scala/sttp/client4/testing/HttpTest.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ trait HttpTest[F[_]]
9292
"as string with mapping using mapResponse" in {
9393
postEcho
9494
.body(testBody)
95-
.mapResponseRight(_.length)
95+
.response(asString.mapRight((_: String).length))
9696
.send(backend)
9797
.toFuture()
9898
.map(response => response.body should be(Right(expectedPostEchoResponse.length)))
@@ -572,7 +572,7 @@ trait HttpTest[F[_]]
572572
}
573573

574574
"redirect when redirects should be followed, and the response is parsed" in {
575-
r2.response(asString).mapResponseRight(_.toInt).send(backend).toFuture().map { resp =>
575+
r2.response(asString.mapRight((_: String).toInt)).send(backend).toFuture().map { resp =>
576576
resp.code shouldBe StatusCode.Ok
577577
resp.body shouldBe Right(r4response.toInt)
578578
}

core/src/test/scalanative/sttp/client4/testing/SyncHttpTest.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ trait SyncHttpTest
6161
"as string with mapping using mapResponse" in {
6262
val response = postEcho
6363
.body(testBody)
64-
.mapResponseRight(_.length)
64+
.response(asString.mapRight((_: String).length))
6565
.send(backend)
6666
response.body should be(Right(expectedPostEchoResponse.length))
6767
}

0 commit comments

Comments
 (0)