aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoradamw <adam@warski.org>2017-07-24 17:05:07 +0200
committeradamw <adam@warski.org>2017-07-24 17:05:07 +0200
commit81d290bc8658841f48d8a7fc10d88813eba16ffc (patch)
tree04ddb3defcfd65b041ec58046958a808a475b512
parentb5f0c5387f7a98875f60fdf09c8dbe56e5c2766d (diff)
downloadsttp-81d290bc8658841f48d8a7fc10d88813eba16ffc.tar.gz
sttp-81d290bc8658841f48d8a7fc10d88813eba16ffc.tar.bz2
sttp-81d290bc8658841f48d8a7fc10d88813eba16ffc.zip
Hiding specific implementation types
-rw-r--r--akka-http-handler/src/main/scala/com/softwaremill/sttp/akkahttp/AkkaHttpSttpHandler.scala6
-rw-r--r--async-http-client-handler/future/src/main/scala/com/softwaremill/sttp/asynchttpclient/future/FutureAsyncHttpClientHandler.scala7
-rw-r--r--async-http-client-handler/monix/src/main/scala/com/softwaremill/sttp/asynchttpclient/monix/MonixAsyncHttpClientHandler.scala7
-rw-r--r--async-http-client-handler/scalaz/src/main/scala/com/softwaremill/sttp/asynchttpclient/scalaz/ScalazAsyncHttpClientHandler.scala7
-rw-r--r--core/src/main/scala/com/softwaremill/sttp/SttpHandler.scala1
5 files changed, 17 insertions, 11 deletions
diff --git a/akka-http-handler/src/main/scala/com/softwaremill/sttp/akkahttp/AkkaHttpSttpHandler.scala b/akka-http-handler/src/main/scala/com/softwaremill/sttp/akkahttp/AkkaHttpSttpHandler.scala
index 34b7df4..49446f2 100644
--- a/akka-http-handler/src/main/scala/com/softwaremill/sttp/akkahttp/AkkaHttpSttpHandler.scala
+++ b/akka-http-handler/src/main/scala/com/softwaremill/sttp/akkahttp/AkkaHttpSttpHandler.scala
@@ -195,7 +195,8 @@ object AkkaHttpSttpHandler {
* context.
*/
def apply()(
- implicit ec: ExecutionContext = ExecutionContext.Implicits.global) =
+ implicit ec: ExecutionContext = ExecutionContext.Implicits.global)
+ : SttpHandler[Future, Source[ByteString, Any]] =
new AkkaHttpSttpHandler(ActorSystem("sttp"), ec, true)
/**
@@ -206,6 +207,7 @@ object AkkaHttpSttpHandler {
* context.
*/
def usingActorSystem(actorSystem: ActorSystem)(
- implicit ec: ExecutionContext = ExecutionContext.Implicits.global) =
+ implicit ec: ExecutionContext = ExecutionContext.Implicits.global)
+ : SttpHandler[Future, Source[ByteString, Any]] =
new AkkaHttpSttpHandler(actorSystem, ec, false)
}
diff --git a/async-http-client-handler/future/src/main/scala/com/softwaremill/sttp/asynchttpclient/future/FutureAsyncHttpClientHandler.scala b/async-http-client-handler/future/src/main/scala/com/softwaremill/sttp/asynchttpclient/future/FutureAsyncHttpClientHandler.scala
index 11808d3..b0a36f9 100644
--- a/async-http-client-handler/future/src/main/scala/com/softwaremill/sttp/asynchttpclient/future/FutureAsyncHttpClientHandler.scala
+++ b/async-http-client-handler/future/src/main/scala/com/softwaremill/sttp/asynchttpclient/future/FutureAsyncHttpClientHandler.scala
@@ -2,6 +2,7 @@ package com.softwaremill.sttp.asynchttpclient.future
import java.nio.ByteBuffer
+import com.softwaremill.sttp.SttpHandler
import com.softwaremill.sttp.asynchttpclient.{
AsyncHttpClientHandler,
MonadAsyncError
@@ -39,7 +40,7 @@ object FutureAsyncHttpClientHandler {
*/
def apply()(
implicit ec: ExecutionContext = ExecutionContext.Implicits.global)
- : FutureAsyncHttpClientHandler =
+ : SttpHandler[Future, Nothing] =
new FutureAsyncHttpClientHandler(new DefaultAsyncHttpClient(),
closeClient = true)
@@ -50,7 +51,7 @@ object FutureAsyncHttpClientHandler {
*/
def usingConfig(cfg: AsyncHttpClientConfig)(
implicit ec: ExecutionContext = ExecutionContext.Implicits.global)
- : FutureAsyncHttpClientHandler =
+ : SttpHandler[Future, Nothing] =
new FutureAsyncHttpClientHandler(new DefaultAsyncHttpClient(),
closeClient = true)
@@ -61,7 +62,7 @@ object FutureAsyncHttpClientHandler {
*/
def usingClient(client: AsyncHttpClient)(implicit ec: ExecutionContext =
ExecutionContext.Implicits.global)
- : FutureAsyncHttpClientHandler =
+ : SttpHandler[Future, Nothing] =
new FutureAsyncHttpClientHandler(client, closeClient = false)
}
diff --git a/async-http-client-handler/monix/src/main/scala/com/softwaremill/sttp/asynchttpclient/monix/MonixAsyncHttpClientHandler.scala b/async-http-client-handler/monix/src/main/scala/com/softwaremill/sttp/asynchttpclient/monix/MonixAsyncHttpClientHandler.scala
index 8e6c70d..2357c06 100644
--- a/async-http-client-handler/monix/src/main/scala/com/softwaremill/sttp/asynchttpclient/monix/MonixAsyncHttpClientHandler.scala
+++ b/async-http-client-handler/monix/src/main/scala/com/softwaremill/sttp/asynchttpclient/monix/MonixAsyncHttpClientHandler.scala
@@ -2,6 +2,7 @@ package com.softwaremill.sttp.asynchttpclient.monix
import java.nio.ByteBuffer
+import com.softwaremill.sttp.SttpHandler
import com.softwaremill.sttp.asynchttpclient.{
AsyncHttpClientHandler,
MonadAsyncError
@@ -43,7 +44,7 @@ object MonixAsyncHttpClientHandler {
* global scheduler.
*/
def apply()(implicit s: Scheduler = Scheduler.Implicits.global)
- : MonixAsyncHttpClientHandler =
+ : SttpHandler[Task, Observable[ByteBuffer]] =
new MonixAsyncHttpClientHandler(new DefaultAsyncHttpClient(),
closeClient = true)
@@ -53,7 +54,7 @@ object MonixAsyncHttpClientHandler {
*/
def usingConfig(cfg: AsyncHttpClientConfig)(implicit s: Scheduler =
Scheduler.Implicits.global)
- : MonixAsyncHttpClientHandler =
+ : SttpHandler[Task, Observable[ByteBuffer]] =
new MonixAsyncHttpClientHandler(new DefaultAsyncHttpClient(),
closeClient = true)
@@ -63,7 +64,7 @@ object MonixAsyncHttpClientHandler {
*/
def usingClient(client: AsyncHttpClient)(implicit s: Scheduler =
Scheduler.Implicits.global)
- : MonixAsyncHttpClientHandler =
+ : SttpHandler[Task, Observable[ByteBuffer]] =
new MonixAsyncHttpClientHandler(client, closeClient = false)
}
diff --git a/async-http-client-handler/scalaz/src/main/scala/com/softwaremill/sttp/asynchttpclient/scalaz/ScalazAsyncHttpClientHandler.scala b/async-http-client-handler/scalaz/src/main/scala/com/softwaremill/sttp/asynchttpclient/scalaz/ScalazAsyncHttpClientHandler.scala
index f4de2eb..ef06a41 100644
--- a/async-http-client-handler/scalaz/src/main/scala/com/softwaremill/sttp/asynchttpclient/scalaz/ScalazAsyncHttpClientHandler.scala
+++ b/async-http-client-handler/scalaz/src/main/scala/com/softwaremill/sttp/asynchttpclient/scalaz/ScalazAsyncHttpClientHandler.scala
@@ -2,6 +2,7 @@ package com.softwaremill.sttp.asynchttpclient.scalaz
import java.nio.ByteBuffer
+import com.softwaremill.sttp.SttpHandler
import com.softwaremill.sttp.asynchttpclient.{
AsyncHttpClientHandler,
MonadAsyncError
@@ -31,13 +32,13 @@ class ScalazAsyncHttpClientHandler private (asyncHttpClient: AsyncHttpClient,
}
object ScalazAsyncHttpClientHandler {
- def apply(): ScalazAsyncHttpClientHandler =
+ def apply(): SttpHandler[Task, Nothing] =
new ScalazAsyncHttpClientHandler(new DefaultAsyncHttpClient(),
closeClient = true)
- def usingConfig(cfg: AsyncHttpClientConfig): ScalazAsyncHttpClientHandler =
+ def usingConfig(cfg: AsyncHttpClientConfig): SttpHandler[Task, Nothing] =
new ScalazAsyncHttpClientHandler(new DefaultAsyncHttpClient(),
closeClient = true)
- def usingClient(client: AsyncHttpClient): ScalazAsyncHttpClientHandler =
+ def usingClient(client: AsyncHttpClient): SttpHandler[Task, Nothing] =
new ScalazAsyncHttpClientHandler(client, closeClient = false)
}
diff --git a/core/src/main/scala/com/softwaremill/sttp/SttpHandler.scala b/core/src/main/scala/com/softwaremill/sttp/SttpHandler.scala
index 0562fc2..800d66a 100644
--- a/core/src/main/scala/com/softwaremill/sttp/SttpHandler.scala
+++ b/core/src/main/scala/com/softwaremill/sttp/SttpHandler.scala
@@ -10,4 +10,5 @@ import scala.language.higherKinds
*/
trait SttpHandler[R[_], -S] {
def send[T](request: Request[T, S]): R[Response[T]]
+ def close(): Unit = {}
}