From e73caaa5c9a4a34ccd10d8e18614199f49fb1d1c Mon Sep 17 00:00:00 2001 From: simpadjo Date: Mon, 11 Jan 2021 23:44:45 +0100 Subject: [PATCH] simplify BookExample --- .../main/scala/sttp/tapir/examples/BooksExample.scala | 8 ++------ .../scala/sttp/tapir/examples/BooksExampleSemiauto.scala | 9 ++------- .../src/main/scala/sttp/tapir/example/BooksExample.scala | 8 ++------ 3 files changed, 6 insertions(+), 19 deletions(-) diff --git a/examples/src/main/scala/sttp/tapir/examples/BooksExample.scala b/examples/src/main/scala/sttp/tapir/examples/BooksExample.scala index 75d4fbcb39..40e6a61cb1 100644 --- a/examples/src/main/scala/sttp/tapir/examples/BooksExample.scala +++ b/examples/src/main/scala/sttp/tapir/examples/BooksExample.scala @@ -152,13 +152,9 @@ object BooksExample extends App with StrictLogging { import sttp.client3._ import sttp.tapir.client.sttp.SttpClientInterpreter - val backend: SttpBackend[Identity, Any] = HttpURLConnectionBackend() + val client = SttpClientInterpreter.toQuickClient(booksListing,Some(uri"http://localhost:8080")) - val booksListingRequest: Request[Either[String, Vector[Book]], Any] = SttpClientInterpreter - .toRequestThrowDecodeFailures(booksListing, Some(uri"http://localhost:8080")) - .apply(Option(3)) - - val result: Either[String, Vector[Book]] = booksListingRequest.send(backend).body + val result: Either[String, Vector[Book]] = client(Some(3)) logger.info("Result of listing request with limit 3: " + result) } diff --git a/examples/src/main/scala/sttp/tapir/examples/BooksExampleSemiauto.scala b/examples/src/main/scala/sttp/tapir/examples/BooksExampleSemiauto.scala index 5d59eb8d40..21a940c2d6 100644 --- a/examples/src/main/scala/sttp/tapir/examples/BooksExampleSemiauto.scala +++ b/examples/src/main/scala/sttp/tapir/examples/BooksExampleSemiauto.scala @@ -158,14 +158,9 @@ object BooksExampleSemiauto extends App with StrictLogging { import sttp.client3._ import sttp.tapir.client.sttp.SttpClientInterpreter - val backend: SttpBackend[Identity, Any] = HttpURLConnectionBackend() - - val booksListingRequest: Request[Either[String, Vector[Book]], Any] = SttpClientInterpreter - .toRequestThrowDecodeFailures(booksListing, Some(uri"http://localhost:8080")) - .apply(Option(3)) - - val result: Either[String, Vector[Book]] = booksListingRequest.send(backend).body + val client = SttpClientInterpreter.toQuickClient(booksListing,Some(uri"http://localhost:8080")) + val result: Either[String, Vector[Book]] = client(Some(3)) logger.info("Result of listing request with limit 3: " + result) } diff --git a/playground/src/main/scala/sttp/tapir/example/BooksExample.scala b/playground/src/main/scala/sttp/tapir/example/BooksExample.scala index c657647819..1743451615 100644 --- a/playground/src/main/scala/sttp/tapir/example/BooksExample.scala +++ b/playground/src/main/scala/sttp/tapir/example/BooksExample.scala @@ -114,13 +114,9 @@ object BooksExample extends App with StrictLogging { import sttp.client3._ import sttp.tapir.client.sttp._ - val backend: SttpBackend[Identity, Any] = HttpURLConnectionBackend() + val client = SttpClientInterpreter.toQuickClient(booksListing,Some(uri"http://localhost:8080")) - val booksListingRequest: Request[Either[String, Vector[Book]], Any] = SttpClientInterpreter - .toRequestThrowDecodeFailures(booksListing, Some(uri"http://localhost:8080")) - .apply(Option(3)) - - val result: Either[String, Vector[Book]] = booksListingRequest.send(backend).body + val result: Either[String, Vector[Book]] = client(Some(3)) logger.info("Result of listing request with limit 3: " + result) }