com.twitter.finatra.http.response
Return a response with the given com.twitter.io.Buf set as the response body.
Return a response with the given com.twitter.io.Buf set as the response body.
the com.twitter.io.Buf to set as the response body.
an EnrichedResponse with the given com.twitter.io.Buf set as the response body.
Return a response with the given InputStream written as bytes as the response body.
Return a response with the given InputStream written as bytes as the response body.
the InputStream to write as bytes as the response body.
an EnrichedResponse with the given InputStream written as an Array[Byte] as the response body.
this fully buffers the InputStream as an Array[Byte] and copies it as the response body. The given input stream is closed after writing the response body.
Return a response with the given String written as the response body.
Return a response with the given String written as the response body.
the String to write as the response body.
an EnrichedResponse with the given String written as the response body.
Return a response with the given Array[Byte] written as the response body.
Return a response with the given Array[Byte] written as the response body.
bytes to write as the response body.
an EnrichedResponse with the given Array[Byte] written as the response body.
this uses com.twitter.io.Buf.ByteArray.Owned to set the response content.
com.twitter.io.Buf.ByteArray.Owned
Return a response with a written body potentially based on values contained within the com.twitter.finagle.http.Request.
Return a response with a written body potentially based on values contained within the com.twitter.finagle.http.Request.
the com.twitter.finagle.http.Request associated with this response.
the body, or the information needed to render the body.
an EnrichedResponse with the given object written as the response body.
This version is useful when the any
parameter requires custom
message body rendering and values in the Request
are required for
decision making.
Return a response with the given object as the written response body.
Return a response with the given object as the written response body. The object is pattern-matched to set the body and content type appropriately.
the body, or the information needed to render the body.
an EnrichedResponse with the given object written as the response body.
Set the "Content-Type" response header field of this EnrichedResponse to the given String.
Set the "Content-Type" response header field of this EnrichedResponse to the given String.
the String to set a the header value.
an EnrichedResponse with the "Content-Type" response header field set to given media type.
Set the "Content-Type" header field for this EnrichedResponse to "application/json".
Set the "Content-Type" header field for this EnrichedResponse to "application/json".
an EnrichedResponse with a the response header "Content-Type" field set to "application/json".
Set the given com.twitter.finagle.http.Cookie on the returned Response.
Set the given com.twitter.finagle.http.Cookie on the returned Response.
the com.twitter.finagle.http.Cookie to set.
an EnrichedResponse with a created Cookie of name with value.
Set a com.twitter.finagle.http.Cookie with the given name and value on the returned Response.
Set a com.twitter.finagle.http.Cookie with the given name and value on the returned Response.
com.twitter.finagle.http.Cookie name
com.twitter.finagle.http.Cookie value
an EnrichedResponse with a created com.twitter.finagle.http.Cookie of name with value.
Helper method for returning responses that are the result of a "service-level" failure.
Helper method for returning responses that are the result of a "service-level" failure. This is most commonly useful in an com.twitter.finatra.http.exceptions.ExceptionMapper implementation. E.g.,
the com.twitter.finagle.http.Request that triggered the failure
the DetailedNonRetryableSourcedException exception to classify
this EnrichedResponse
Helper method for returning responses that are the result of a "service-level" failure.
Helper method for returning responses that are the result of a "service-level" failure. This is most commonly useful in an com.twitter.finatra.http.exceptions.ExceptionMapper implementation. E.g.,
@Singleton class AuthenticationExceptionMapper @Inject()( response: ResponseBuilder) extends ExceptionMapper[AuthenticationException] { override def toResponse( request: Request, exception: AuthenticationException ): Response = { response .status(exception.status) .failureClassifier( is5xxStatus(exception.status), request, exception) .jsonError(s"Your account could not be authenticated. Reason: ${exception.resultCode}") } }
the com.twitter.finagle.http.Request that triggered the failure
The named component responsible for causing this failure.
Details about this exception suitable for stats. Each element will be converted into a string. Note: Each element must have a bounded set of values (e.g. You can stat the type of a tweet as "protected" or "unprotected", but you can't include the actual tweet id "696081566032723968").
Details about this exception to be logged when this exception occurs. Typically logDetails contains the unbounded details of the exception that you are not able to stat such as an actual tweet ID (see above)
this EnrichedResponse
Helper method for returning responses that are the result of a "service-level" failure.
Helper method for returning responses that are the result of a "service-level" failure. This is most commonly useful in an com.twitter.finatra.http.exceptions.ExceptionMapper implementation.
if the failure should be "classified", e.g. logged and stat'd accordingly
the com.twitter.finagle.http.Request that triggered the failure
The named component responsible for causing this failure.
Details about this exception suitable for stats. Each element will be converted into a string. Note: Each element must have a bounded set of values (e.g. You can stat the type of a tweet as "protected" or "unprotected", but you can't include the actual tweet id "696081566032723968").
Details about this exception to be logged when this exception occurs. Typically logDetails contains the unbounded details of the exception that you are not able to stat such as an actual tweet ID (see above).
this EnrichedResponse
Helper method for returning responses that are the result of a "service-level" failure.
Helper method for returning responses that are the result of a "service-level" failure. This is most commonly useful in an com.twitter.finatra.http.exceptions.ExceptionMapper implementation. E.g.,
if the failure should be "classified", e.g. logged and stat'd accordingly
the com.twitter.finagle.http.Request that triggered the failure
the DetailedNonRetryableSourcedException exception to classify
this EnrichedResponse
Return a response resolving the given file path to a java.io.File using the configured com.twitter.finatra.utils.FileResolver.
Return a response resolving the given file path to a java.io.File using the configured com.twitter.finatra.utils.FileResolver. The resolved java.io.File is set as bytes as the response body. The file contents are fully buffered and copied to an Array[Byte] before being written as the response body.
the file String to resolve as a java.io.File to write as the response body.
an EnrichedResponse with the given file written as an Array[Byte] as the response body.
The resolved file is closed after writing the response body.
Return a response with the given java.io.File bytes as the response body.
Return a response with the given java.io.File bytes as the response body. The file contents are fully buffered and copied to an Array[Byte] before being written as the response body.
the java.io.File to write as the response body.
an EnrichedResponse with the given file written as an Array[Byte] as the response body.
The given java.io.File is closed after writing the response body.
Return the file (only if it's an existing file w/ an extension), otherwise return the index.
Return the file (only if it's an existing file w/ an extension), otherwise return the index. Note: This functionality is useful for "single-page" UI frameworks (e.g. AngularJS) that perform client side routing.
the file path to resolve and return
the index path to use when the file at the given filePath does not exist or does not specify an extension.
an EnrichedResponse with the resolved file or index written as an Array[Byte] as the response body.
String)
Return a response with the given response header key/value set.
Return a response with the given response header key/value set.
the response header key to set.
the response header object to set. This method calls toString
on this parameter
to compute the String value.
an EnrichedResponse with the given response header field to the given value.
Return a response with the given response headers set.
Return a response with the given response headers set.
the sequence of Tuple2 response header key/values to set.
an EnrichedResponse with each response header field set to its tupled value.
Return a response with the given response headers set.
Return a response with the given response headers set.
the map of response header key/values to set.
an EnrichedResponse with each response header field set to its mapped value.
Return a response with the given object written as a HTML response body.
Return a response with the given object written as a HTML response body. Sets the "Content-Type" header field for this EnrichedResponse to "text/html". The object is pattern-matched to set the response body appropriately.
the object to write as an HTML response body.
an EnrichedResponse with the given object written as an HTML response body.
the content type can be overridden depending on if there is a registered MessageBodyManager for the given object type that specifies a different content type than "text/html".
Return a response with the given String written as a HTML response body.
Return a response with the given String written as a HTML response body. Sets the "Content-Type" header field for this EnrichedResponse to "text/html".
the String to write as an HTML response body.
an EnrichedResponse with the given String written as an HTML response body.
Return a JSON-formatted body from the given object.
Return a JSON-formatted body from the given object. Note when either String or Array[Byte] data is passed the data is set as the response body unmodified, i.e., assumes the data is already JSON formatted).
The purpose of this method is to convert an object into a JSON-formatted body via the defined ObjectMapper.
Sets the response "Content-Type" header to "application/json"
object to convert into a JSON-formatted body.
an EnrichedResponse with a JSON body.
Create a JSON-formatted ErrorsResponse response body based on the given string.
Create a JSON-formatted ErrorsResponse response body based on the given string.
string message over which to create a JSON-formatted ErrorsResponse.
an EnrichedResponse with a JSON-formatted ErrorsResponse response body.
Create a JSON-formatted ErrorsResponse response body based on this response's current com.twitter.finagle.http.Status.
Create a JSON-formatted ErrorsResponse response body based on this response's current com.twitter.finagle.http.Status.
an EnrichedResponse with a JSON-formatted ErrorsResponse response body.
com.twitter.finagle.http.Status
Return a response with the "Location" response header field set to the given URI value.
Return a response with the "Location" response header field set to the given URI value.
the String value to set as the header value.
an EnrichedResponse with a set "Location" response header.
Return a response with the "Location" response header field set to the given URI value.
Return a response with the "Location" response header field set to the given URI value.
the value to set as the header value. This method calls toString
on
this parameter to compute the String value.
an EnrichedResponse with a set "Location" response header.
Return a response with the given object written as a plaintext response body.
Return a response with the given object written as a plaintext response body. Sets the "Content-Type" header field for this EnrichedResponse to "text/plain".
the object to write as a plaintext response body.
an EnrichedResponse with the given object written as a plaintext response body.
Returns a HttpResponseException built from the Response wrapped by this EnrichedResponse
Returns a HttpResponseException built from the Response wrapped by this EnrichedResponse
a new HttpResponseException over the response
HttpResponseException
Returns this EnrichedResponse wrapped in a com.twitter.util.Future
Returns this EnrichedResponse wrapped in a com.twitter.util.Future
a Future[Response]]
Returns a failed Future of type [T] containing the result of EnrichedResponse#toException.
Returns a failed Future of type [T] containing the result of EnrichedResponse#toException.
the type of the Future
a "failed" Future.
com.twitter.util.Future#exception
A wrapper around a com.twitter.finagle.http.Response which is itself a type of com.twitter.finagle.http.Response (by virtue of extending com.twitter.finagle.http.ResponseProxy
This class exposes a builder-like API for creating an com.twitter.finagle.http.Response. Users are NOT expected to interact with this class directly but should instead use the methods in the com.twitter.finatra.http.response.ResponseBuilder which return this specialized com.twitter.finagle.http.Response type.
Usage is through com.twitter.finatra.http.response.ResponseBuilder
com.twitter.finatra.http.response.ResponseBuilder
com.twitter.finagle.http.Response