Context containing information needed to service the request, such as the parent actor
This method is overridden by the end-user to execute the requests served by this resource.
This method is overridden by the end-user to execute the requests served by this resource. The ParsedRequest object will be sent to this message from ResourceActor via a tell. As an actor will be spun up for each request, it is safe to store mutable state during this receive function. When the request is finished, one of the provided complete methods must be called
This receive should handle
ProcessRequest(_)
messages.
ProcessRequest(_) }}}
The receive function to be applied when a parsed request object or other actor message is received
A list of content types that that this server can accept, by default application/json
.
A list of content types that that this server can accept, by default application/json
.
These will be matched against the Content-Type
header of incoming requests.
a list of content types
This method will always be invoked after request processing is finished.
This method will always be invoked after request processing is finished.
If the method throws, the error will be logged and the given response will still be returned. As always, personally identifiable information should never be included in exception messages.
The response to be returned to the client
This method will always be invoked before request processing begins.
This method will always be invoked before request processing begins. It is primarily provided for metrics tracking.
If the method throws, an error response will be returned. The response will be determined by createErrorResponse. As always, personally identifiable information should never be included in exception messages.
The Http method of the request in question
Complete a successful request
Complete a successful request
The HttpResponse to be returned
Value for the HTTP location header
Complete a successful request
Complete a successful request
The HttpResponse to be returned
Complete a successful request with a JSON response
Complete a successful request with a JSON response
Type of the object to be returned
Status code to return
Object to be serialized in the response
Value for the HTTP Location header
Complete a successful request with a JSON response
Complete a successful request with a JSON response
Type of the object to be returned
Status code to return
Object to be serialized in the response
Creates an appropriate HttpResponse for a given exception.
Creates an appropriate HttpResponse for a given exception.
the exception
a crafted HttpResponse from the error message
Creates an appropriate error message for when a request could not be parsed.
Creates an appropriate error message for when a request could not be parsed.
the throwable which caused the error
a message describing the parsing error
The receive function for this resource.
The receive function for this resource. Should not be overridden - implement resourceReceive instead
The content type that this server provides, by default application/json
The content type that this server provides, by default application/json
a list of content types
The language of the data in the response, to for the Content-Language header
The language of the data in the response, to for the Content-Language header
a spray.http.Language value in an Option, or None, if the Content-Language header does not need to be set for this resource
Return an internal server error in response to a throwable.
Return an internal server error in response to a throwable. The type of the throwable should have a case in createErrorResponse.
The error to be used for server response.
Return an error with the specified Status code
Return an error with the specified Status code
The error code to return
Return an error with the specified status code and error object.
Return an error with the specified status code and error object.
Type of the error
The error code to return
Error to return, will be converted to JSON
crash on unhandled exceptions
crash on unhandled exceptions
A scheduled task which times the request out after the resourceTimeout.
A scheduled task which times the request out after the resourceTimeout. See the Akka Scheduler documentation.
a Cancellable which will run after the context timeout unless it is cancelled via its cancel method.
Base class for HTTP resources built with Spray.