aboutsummaryrefslogtreecommitdiff
path: root/core/src/main/scala/com/softwaremill/sttp/SttpBackend.scala
diff options
context:
space:
mode:
Diffstat (limited to 'core/src/main/scala/com/softwaremill/sttp/SttpBackend.scala')
-rw-r--r--core/src/main/scala/com/softwaremill/sttp/SttpBackend.scala26
1 files changed, 26 insertions, 0 deletions
diff --git a/core/src/main/scala/com/softwaremill/sttp/SttpBackend.scala b/core/src/main/scala/com/softwaremill/sttp/SttpBackend.scala
new file mode 100644
index 0000000..6eb312f
--- /dev/null
+++ b/core/src/main/scala/com/softwaremill/sttp/SttpBackend.scala
@@ -0,0 +1,26 @@
+package com.softwaremill.sttp
+
+import scala.language.higherKinds
+import scala.concurrent.duration._
+
+/**
+ * @tparam R The type constructor in which responses are wrapped. E.g. `Id`
+ * for synchronous backends, `Future` for asynchronous backends.
+ * @tparam S The type of streams that are supported by the backend. `Nothing`,
+ * if streaming requests/responses is not supported by this backend.
+ */
+trait SttpBackend[R[_], -S] {
+ def send[T](request: Request[T, S]): R[Response[T]]
+
+ def close(): Unit
+
+ /**
+ * The monad in which the responses are wrapped. Allows writing wrapper
+ * backends, which map/flatMap over the return value of [[send]].
+ */
+ def responseMonad: MonadError[R]
+}
+
+object SttpBackend {
+ private[sttp] val DefaultConnectionTimeout = 30.seconds
+}