Base class for HTTP resources built with Spray.
Specialized Exception type that encodes an HTTP error response, including an error code
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
For resources that do not perform any degree of authorization of incoming requests
For resources that do not expect a body in 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.
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.
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.
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())))
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())))
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(...))
the left type, by convention representing a failure
the right type, by convention representing a success
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()))
the right type of the either
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(...)))
the success type of the future
Implicit wrapper to allow anything to continue
Implicit wrapper to allow anything to continue
import com.paypal.cascade.http.resource._ "hi".continue // Future("hi")
the type of this object
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")
the type of the wrapped option
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")
the type of the wrapped option
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())))
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())))
the success type of the try
Convenience methods
Implementation of a basic HTTP request handling pipeline.
Implementation of a basic HTTP request handling pipeline. Used to push along HTTP requests.
Stop further processing, and yield an error response
Stop further processing, and yield an error response
the expected return type, if processing were to continue
the response code to return
the response body to return, if any
headers to return in the response, if any
a failed Future, containing an error response
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 formorHaltT
return a Try.