com.pagerduty.funhttpclient

Http

case class Http[E, A] extends HttpInstances with Product with Serializable

A computation that involves remote requests over HTTP.

Http computations are asynchronous, log HTTP requests that are made, and have explicit error handling (without exceptions).

They have a simple functional interface consisting of:

as well as additional functions for error handling by-value.

Http computations can have one of two outcomes: an error of type E or a result of type A.

Errors short-circuit computations and are threaded to the final result.

Http computations should be converted to Scala futures via asFuture or asFutureWithLog for further computation.

To those with functional programming experience, an Http is essentially a monad transformer consisting of an either, a writer, and a Scala Future.

Linear Supertypes
Serializable, Serializable, Product, Equals, HttpInstances, AnyRef, Any
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. Http
  2. Serializable
  3. Serializable
  4. Product
  5. Equals
  6. HttpInstances
  7. AnyRef
  8. Any
  1. Hide All
  2. Show all
Learn more about member selection
Visibility
  1. Public
  2. All

Type Members

  1. type D[E, A] = EitherT[W, E, A]

    Definition Classes
    HttpInstances
  2. type H[E, A] = Http[E, A]

    Definition Classes
    HttpInstances
  3. trait MonadErrorInstance[E] extends MonadError[H, E] with MonadInstance[E]

    Definition Classes
    HttpInstances
  4. trait MonadInstance[E] extends Monad[[X]Http[E, X]]

    Definition Classes
    HttpInstances
  5. type RequestLog = Vector[LogEntry]

    Definition Classes
    HttpInstances
  6. type W[A] = WriterT[Future, RequestLog, A]

    Definition Classes
    HttpInstances

Value Members

  1. final def !=(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  2. final def !=(arg0: Any): Boolean

    Definition Classes
    Any
  3. final def ##(): Int

    Definition Classes
    AnyRef → Any
  4. final def ==(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  5. final def ==(arg0: Any): Boolean

    Definition Classes
    Any
  6. def andThen[B](fb: Http[E, B]): Http[E, B]

    Sequence two computations, disregarding the result of the first.

    Sequence two computations, disregarding the result of the first.

    Example
    val say = HttpOps[String].unit(println("Hello!"))
    val x = say andThen HttpOps[String].unit(3)
    
    scala> :t x
    com.pagerduty.sprayfunclient.Http[String, Int]
  7. def asFuture: Future[\/[E, A]]

    Like asFutureWithLog, but without the request log.

  8. def asFutureEither: Future[Either[E, A]]

    Like asFuture, but with the error computation as an Either type.

    Like asFuture, but with the error computation as an Either type.

    See also

    asFuture

  9. def asFutureOption: Future[Option[A]]

    Finalize the HTTP computation without caring about the error type.

    Finalize the HTTP computation without caring about the error type.

    Any error value is converted to None.

    See also

    asFuture, asFutureWithLog

  10. def asFutureThrowable(implicit evidence: <:<[E, Throwable]): Future[A]

    Like asFuture, but in the case of error, the future is failed.

    Like asFuture, but in the case of error, the future is failed.

    This method requires that there is evidence that the error type is a sub-class of Throwable.

  11. def asFutureWithLog: Future[(RequestLog, \/[E, A])]

    Finalize the HTTP computation by getting the underlying future value.

    Finalize the HTTP computation by getting the underlying future value.

    The result of the computation is the log of HTTP requests made as well as the computation (or the error that occurred).

    Example
    import scala.concurrent._
    import scala.concurrent.duration._
    
    val x = HttpOps[String].unit(3)
    val fut = x.map(_ * 2).asFutureWithLog
    
    scala> Await.result(fut, Duration.Inf)
    res0: (Vector[LogEntry], \/[String,Int]) = (Vector(),\/-(6))
  12. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  13. def clone(): AnyRef

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  14. final def eq(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  15. def finalize(): Unit

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  16. def flatMap[B](f: (A) ⇒ Http[E, B]): Http[E, B]

    Example
    scala> :t HttpOps[String].unit(3) flatMap { x => HttpOps[String].unit(x.toDouble) }
    com.pagerduty.sprayfunclient.Http[String,Double]
  17. final def getClass(): Class[_]

    Definition Classes
    AnyRef → Any
  18. def handleError(f: (E) ⇒ Http[E, A]): Http[E, A]

    Recover from errors.

    Recover from errors.

    Example
    val badComputation = HttpOps[String].raiseError[Int]("error1")
    
    for {
      x <- HttpOps[String].unit(5)
    
      y <- badComputation handleError {
        case "error1" => HttpOps[String].async(3)
      }
    } yield x + y
  19. val httpOps: HttpOps[E]

  20. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  21. def map[B](f: (A) ⇒ B): Http[E, B]

    Map over the successful result of the computation.

    Map over the successful result of the computation.

    Example
    scala> :t HttpOps[String].unit(3).map(_.toDouble)
    com.pagerduty.sprayfunclient.Http[String,Double]
  22. def mapError[EE](f: (E) ⇒ EE): Http[EE, A]

    Map over the result of a failed computation.

    Map over the result of a failed computation.

    Example==
    case class BadThing(message: String)
    
    val x = HttpOps[String].async(3)
    
    scala> :t x.mapError(BadThing.apply)
    com.pagerduty.sprayfunclient.Http[BadThing, Int]
  23. implicit def monad[E]: MonadInstance[E]

    Definition Classes
    HttpInstances
  24. implicit def monadError[E]: MonadErrorInstance[E]

    Definition Classes
    HttpInstances
  25. final def ne(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  26. final def notify(): Unit

    Definition Classes
    AnyRef
  27. final def notifyAll(): Unit

    Definition Classes
    AnyRef
  28. val run: EitherT[[X]WriterT[Future, Vector[LogEntry], X], E, A]

  29. final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
    AnyRef
  30. final def wait(): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  31. final def wait(arg0: Long, arg1: Int): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  32. final def wait(arg0: Long): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from Serializable

Inherited from Serializable

Inherited from Product

Inherited from Equals

Inherited from HttpInstances

Inherited from AnyRef

Inherited from Any

Ungrouped