aboutsummaryrefslogtreecommitdiff
path: root/core/src/main/scala/com/softwaremill/sttp/SttpBackend.scala
blob: 6eb312fa9e40e88db3f3e57ce21d43cebc069efc (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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
}