com.paypal.cascade.http

resource

package resource

Utility methods for turning everyday datatypes into Trys and Futures that can possibly return a com.paypal.cascade.http.resource.HaltException. Methods of the form orHalt create a Future. Methods of the form orHaltT return a Try.

Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. resource
  2. AnyRef
  3. Any
  1. Hide All
  2. Show all
Learn more about member selection
Visibility
  1. Public
  2. All

Type Members

  1. abstract class AbstractResourceActor extends HttpResourceActor

    Base class for HTTP resources built with Spray.

  2. case class HaltException(response: HttpResponse) extends Exception with Product with Serializable

    Specialized Exception type that encodes an HTTP error response, including an error code

  3. abstract class HttpResourceActor extends ServiceActor

    the actor to manage the execution of an com.paypal.cascade.http.resource.AbstractResourceActor.

    the actor to manage the execution of an com.paypal.cascade.http.resource.AbstractResourceActor. Create one of these per request

  4. type NoAuth = Unit

    For resources that do not perform any degree of authorization of incoming requests

  5. type NoBody = Option[String]

    For resources that do not expect a body in requests

  6. trait NoParsing extends AnyRef

    Mix this into an com.paypal.cascade.http.resource.AbstractResourceActor implementation and use spray.http.HttpRequest as the ParsedRequest type to perform no additional parsing of incoming requests.

    Mix this into an com.paypal.cascade.http.resource.AbstractResourceActor implementation and use spray.http.HttpRequest as the ParsedRequest type to perform no additional parsing of incoming requests. Useful for status endpoints, etc.

  7. trait ResourceServiceComponent extends AnyRef

    Base type for implementing resource-based services.

    Base type for implementing resource-based services. Contains several often-used patterns, e.g. stats and status endpoints, and is driven by com.paypal.cascade.http.resource.ResourceDriver.

    Implementing classes should override route with their own Spray route logic. This should serve as the top-most actor (or very close to top) in a Spray-based actor hierarchy, as it is the first point of entry into most services.

  8. implicit class RichBooleanFutureHalt extends AnyRef

    Implicit wrapper to allow Booleans to halt or throw

    Implicit wrapper to allow Booleans to halt or throw

    import com.paypal.cascade.http.resource._
    true.orError  // Future({})
    false.orError // Future(HaltException(HttpResponse(500, Empty, List())))
  9. implicit class RichBooleanTryHalt extends AnyRef

    Implicit wrapper to allow Booleans to halt or throw

    Implicit wrapper to allow Booleans to halt or throw

    import com.paypal.cascade.http.resource._
    true.orError  // Try({})
    false.orError // Try(HaltException(HttpResponse(500, Empty, List())))
  10. implicit class RichEitherHalt[T, A] extends AnyRef

    Implicit wrapper to allow right-biased scala.util.Either values, of any left type, to halt or throw

    Implicit wrapper to allow right-biased scala.util.Either values, of any left type, to halt or throw

    import com.paypal.cascade.http.resource._
    Right("hi").orError                                                             // Future("hi")
    Left(CustomError("no")).orError { c => HttpResponse(500, c.getMessage, List()) } // Future(HaltException(...))
    T

    the left type, by convention representing a failure

    A

    the right type, by convention representing a success

  11. implicit class RichEitherThrowableHalt[A] extends AnyRef

    Implicit wrapper to allow right-biased, left Throwable scala.util.Either values to halt or throw

    Implicit wrapper to allow right-biased, left Throwable scala.util.Either values to halt or throw

    import com.paypal.cascade.http.resource._
    Right("hi").orErrorWithMessage                 // Future("hi")
    Left(new Throwable("fail")).orErrorWithMessage // Future(HaltException(500, "fail", List()))
    A

    the right type of the either

  12. implicit class RichFuture[T] extends AnyRef

    Implicit wrapper to allow Futures to halt

    Implicit wrapper to allow Futures to halt

    import com.paypal.cascade.http.resource._
    Future { "hi" }.orHalt { case e: Throwable => HttpResponse(...) }
      // => Future("hi")
    Future { throw new Throwable("fail") }.orHalt { case e: Throwable => HttpResponse(...) }
      // => Future(HaltException(HttpResponse(...)))
    T

    the success type of the future

  13. implicit class RichIdentity[T] extends AnyRef

    Implicit wrapper to allow anything to continue

    Implicit wrapper to allow anything to continue

    import com.paypal.cascade.http.resource._
    "hi".continue  // Future("hi")
    T

    the type of this object

  14. implicit class RichOptionFutureHalt[A] extends AnyRef

    Implicit wrapper to allow optional values to halt or throw

    Implicit wrapper to allow optional values to halt or throw

    import com.paypal.cascade.http.resource._
    Option("hi").orError()  // Future("hi")
    A

    the type of the wrapped option

  15. implicit class RichOptionTryHalt[A] extends AnyRef

    Implicit wrapper to allow optional values to halt or throw

    Implicit wrapper to allow optional values to halt or throw

    import com.paypal.cascade.http.resource._
    Option("hi").orError()  // Future("hi")
    A

    the type of the wrapped option

  16. implicit class RichThrowableHalt extends AnyRef

    Implicit wrapper to allow any Throwable to halt

    Implicit wrapper to allow any Throwable to halt

    import com.paypal.cascade.http.resource._
    (new Throwable("no")).haltWith(InternalServiceError)()  // Future(HaltException(HttpResponse(500, "no", List())))
  17. implicit class RichTryHalt[A] extends RichEitherThrowableHalt[A]

    Implicit wrapper to allow scala.util.Try values to halt or throw.

    Implicit wrapper to allow scala.util.Try values to halt or throw. Handled internally as a right-biased scala.util.Either with a Throwable left.

    import com.paypal.cascade.http.resource._
    Try { "hi" }.orErrorWithMessage()                      // Future("hi")
    Try { throw new Throwable("no") }.orErrorWithMessage() // Future(HaltException(HttpResponse(500, "no", List())))
    A

    the success type of the try

Value Members

  1. object HaltException extends Serializable

    Convenience methods

  2. object HttpResourceActor

  3. object ResourceDriver

    Implementation of a basic HTTP request handling pipeline.

    Implementation of a basic HTTP request handling pipeline. Used to push along HTTP requests.

  4. def halt[T](status: StatusCode, entity: HttpEntity = Empty, headers: List[HttpHeader] = Nil): Future[T]

    Stop further processing, and yield an error response

    Stop further processing, and yield an error response

    T

    the expected return type, if processing were to continue

    status

    the response code to return

    entity

    the response body to return, if any

    headers

    headers to return in the response, if any

    returns

    a failed Future, containing an error response

Inherited from AnyRef

Inherited from Any

Ungrouped