Packages

abstract class EnrichedResponse extends ResponseProxy

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.

Note

Usage is through com.twitter.finatra.http.response.ResponseBuilder

See also

com.twitter.finagle.http.Response

com.twitter.finatra.http.response.ResponseBuilder

Linear Supertypes
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. EnrichedResponse
  2. ResponseProxy
  3. Proxy
  4. Response
  5. Message
  6. AnyRef
  7. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Instance Constructors

  1. new EnrichedResponse()

Abstract Value Members

  1. abstract def body(buffer: Buf): EnrichedResponse

    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.

    buffer

    the com.twitter.io.Buf to set as the response body.

    returns

    an EnrichedResponse with the given com.twitter.io.Buf set as the response body.

  2. abstract def body(inputStream: InputStream): EnrichedResponse

    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.

    inputStream

    the InputStream to write as bytes as the response body.

    returns

    an EnrichedResponse with the given InputStream written as an Array[Byte] as the response body.

    Note

    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.

  3. abstract def body(bodyStr: String): EnrichedResponse

    Return a response with the given String written as the response body.

    Return a response with the given String written as the response body.

    bodyStr

    the String to write as the response body.

    returns

    an EnrichedResponse with the given String written as the response body.

  4. abstract def body(b: Array[Byte]): EnrichedResponse

    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.

    b

    bytes to write as the response body.

    returns

    an EnrichedResponse with the given Array[Byte] written as the response body.

    Note

    this uses com.twitter.io.Buf.ByteArray.Owned to set the response content.

    See also

    com.twitter.io.Buf.ByteArray.Owned

  5. abstract def body(request: Request, any: Any): EnrichedResponse

    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.

    request

    the com.twitter.finagle.http.Request associated with this response.

    any

    the body, or the information needed to render the body.

    returns

    an EnrichedResponse with the given object written as the response body.

    Note

    This version is useful when the any parameter requires custom message body rendering and values in the Request are required for decision making.

  6. abstract def body(any: Any): EnrichedResponse

    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.

    any

    the body, or the information needed to render the body.

    returns

    an EnrichedResponse with the given object written as the response body.

  7. abstract def contentType(mediaType: String): EnrichedResponse

    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.

    mediaType

    the String to set a the header value.

    returns

    an EnrichedResponse with the "Content-Type" response header field set to given media type.

  8. abstract def contentTypeJson(): EnrichedResponse

    Set the "Content-Type" header field for this EnrichedResponse to "application/json".

    Set the "Content-Type" header field for this EnrichedResponse to "application/json".

    returns

    an EnrichedResponse with a the response header "Content-Type" field set to "application/json".

  9. abstract def cookie(c: Cookie): EnrichedResponse

    Set the given com.twitter.finagle.http.Cookie on the returned Response.

    Set the given com.twitter.finagle.http.Cookie on the returned Response.

    c

    the com.twitter.finagle.http.Cookie to set.

    returns

    an EnrichedResponse with a created Cookie of name with value.

    See also

    HTTP Cookie

  10. abstract def cookie(name: String, value: String): EnrichedResponse

    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.

    name

    com.twitter.finagle.http.Cookie name

    value

    com.twitter.finagle.http.Cookie value

    returns

    an EnrichedResponse with a created com.twitter.finagle.http.Cookie of name with value.

    See also

    HTTP Cookie Structure

  11. abstract def failure(request: Request, exception: DetailedNonRetryableSourcedException): 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.,

    request

    the com.twitter.finagle.http.Request that triggered the failure

    exception

    the DetailedNonRetryableSourcedException exception to classify

    returns

    this EnrichedResponse

    See also

    EnrichedResponse#failureClassifier

  12. abstract def failure(request: Request, source: String, details: Seq[Any], message: String = ""): 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}")
     }
    }
    request

    the com.twitter.finagle.http.Request that triggered the failure

    source

    The named component responsible for causing this failure.

    details

    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").

    message

    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)

    returns

    this EnrichedResponse

    See also

    EnrichedResponse#failureClassifier

  13. abstract def failureClassifier(classifier: => Boolean, request: Request, source: String, details: Seq[Any] = Seq(), message: String = ""): 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.

    classifier

    if the failure should be "classified", e.g. logged and stat'd accordingly

    request

    the com.twitter.finagle.http.Request that triggered the failure

    source

    The named component responsible for causing this failure.

    details

    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").

    message

    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).

    returns

    this EnrichedResponse

  14. abstract def failureClassifier(classifier: => Boolean, request: Request, exception: DetailedNonRetryableSourcedException): 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.,

    classifier

    if the failure should be "classified", e.g. logged and stat'd accordingly

    request

    the com.twitter.finagle.http.Request that triggered the failure

    exception

    the DetailedNonRetryableSourcedException exception to classify

    returns

    this EnrichedResponse

    See also

    EnrichedResponse#failureClassifier

  15. abstract def file(file: String): 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.

    file

    the file String to resolve as a java.io.File to write as the response body.

    returns

    an EnrichedResponse with the given file written as an Array[Byte] as the response body.

    Note

    The resolved file is closed after writing the response body.

    See also

    com.twitter.finatra.utils.FileResolver

  16. abstract def file(file: File): EnrichedResponse

    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.

    file

    the java.io.File to write as the response body.

    returns

    an EnrichedResponse with the given file written as an Array[Byte] as the response body.

    Note

    The given java.io.File is closed after writing the response body.

  17. abstract def fileOrIndex(filePath: String, indexPath: String): EnrichedResponse

    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.

    filePath

    the file path to resolve and return

    indexPath

    the index path to use when the file at the given filePath does not exist or does not specify an extension.

    returns

    an EnrichedResponse with the resolved file or index written as an Array[Byte] as the response body.

    See also

    String)

  18. abstract def header(k: String, v: Any): EnrichedResponse

    Return a response with the given response header key/value set.

    Return a response with the given response header key/value set.

    k

    the response header key to set.

    v

    the response header object to set. This method calls toString on this parameter to compute the String value.

    returns

    an EnrichedResponse with the given response header field to the given value.

  19. abstract def headers(entries: (String, Any)*): EnrichedResponse

    Return a response with the given response headers set.

    Return a response with the given response headers set.

    entries

    the sequence of Tuple2 response header key/values to set.

    returns

    an EnrichedResponse with each response header field set to its tupled value.

  20. abstract def headers(map: Map[String, String]): EnrichedResponse

    Return a response with the given response headers set.

    Return a response with the given response headers set.

    map

    the map of response header key/values to set.

    returns

    an EnrichedResponse with each response header field set to its mapped value.

  21. abstract def html(any: Any): EnrichedResponse

    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.

    any

    the object to write as an HTML response body.

    returns

    an EnrichedResponse with the given object written as an HTML response body.

    Note

    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".

  22. abstract def html(html: String): EnrichedResponse

    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".

    html

    the String to write as an HTML response body.

    returns

    an EnrichedResponse with the given String written as an HTML response body.

  23. abstract def json(obj: Any): EnrichedResponse

    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"

    obj

    object to convert into a JSON-formatted body.

    returns

    an EnrichedResponse with a JSON body.

  24. abstract def jsonError(message: String): EnrichedResponse

    Create a JSON-formatted ErrorsResponse response body based on the given string.

    Create a JSON-formatted ErrorsResponse response body based on the given string.

    message

    string message over which to create a JSON-formatted ErrorsResponse.

    returns

    an EnrichedResponse with a JSON-formatted ErrorsResponse response body.

    See also

    ErrorsResponse

  25. abstract def jsonError: EnrichedResponse

    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.

    returns

    an EnrichedResponse with a JSON-formatted ErrorsResponse response body.

    See also

    ErrorsResponse

    com.twitter.finagle.http.Status

  26. abstract def location(uri: String): EnrichedResponse

    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.

    uri

    the String value to set as the header value.

    returns

    an EnrichedResponse with a set "Location" response header.

  27. abstract def location(uri: Any): EnrichedResponse

    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.

    uri

    the value to set as the header value. This method calls toString on this parameter to compute the String value.

    returns

    an EnrichedResponse with a set "Location" response header.

  28. abstract def plain(any: Any): EnrichedResponse

    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".

    any

    the object to write as a plaintext response body.

    returns

    an EnrichedResponse with the given object written as a plaintext response body.

  29. abstract def response: Response
    Definition Classes
    Proxy
  30. abstract def toException: HttpResponseException

    Returns a HttpResponseException built from the Response wrapped by this EnrichedResponse

    Returns a HttpResponseException built from the Response wrapped by this EnrichedResponse

    returns

    a new HttpResponseException over the response

    See also

    HttpResponseException

  31. abstract def toFuture: Future[Response]

    Returns this EnrichedResponse wrapped in a com.twitter.util.Future

    Returns this EnrichedResponse wrapped in a com.twitter.util.Future

    returns

    a Future[Response]]

  32. abstract def toFutureException[T]: Future[T]

    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.

    T

    the type of the Future

    returns

    a "failed" Future.

    See also

    com.twitter.util.Future#exception

Concrete Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##: Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. def addCookie(cookie: Cookie): Unit
    Definition Classes
    Message
  5. def allow: Option[String]
    Definition Classes
    Message
  6. def allow_=(values: Iterable[Method]): Unit
    Definition Classes
    Message
  7. def allow_=(value: String): Unit
    Definition Classes
    Message
  8. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  9. def cacheControl: Option[String]
    Definition Classes
    Message
  10. def cacheControl_=(maxAge: Duration): Unit
    Definition Classes
    Message
  11. def cacheControl_=(value: String): Unit
    Definition Classes
    Message
  12. def charset: Option[String]
    Definition Classes
    Message
  13. def charset_=(value: String): Unit
    Definition Classes
    Message
  14. def chunkReader: Reader[Chunk]
    Definition Classes
    Proxy → Message
  15. def chunkWriter: Writer[Chunk]
    Definition Classes
    Proxy → Message
  16. final def clearContent(): Unit
    Definition Classes
    Message
  17. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @native()
  18. def close(): Future[Unit]
    Definition Classes
    Message
  19. final def content: Buf
    Definition Classes
    Proxy → Message
  20. final def content(content: Buf): EnrichedResponse.this.type
    Definition Classes
    Message
    Annotations
    @throws(scala.this.throws.<init>$default$1[IllegalStateException])
  21. final def contentLength(value: Long): EnrichedResponse.this.type
    Definition Classes
    Message
  22. def contentLength: Option[Long]
    Definition Classes
    Message
  23. final def contentLengthOrElse(default: Long): Long
    Definition Classes
    Message
  24. def contentLength_=(value: Long): Unit
    Definition Classes
    Message
  25. def contentString: String
    Definition Classes
    Message
  26. def contentString_=(value: String): Unit
    Definition Classes
    Message
  27. def contentType: Option[String]
    Definition Classes
    Message
  28. def contentType_=(value: String): Unit
    Definition Classes
    Message
  29. final def content_=(content: Buf): Unit
    Definition Classes
    Proxy → Message
  30. lazy val cookies: CookieMap
    Definition Classes
    Proxy → Message
  31. def ctx: Record
    Definition Classes
    Proxy → Response
  32. def date: Option[String]
    Definition Classes
    Message
  33. def date_=(value: Date): Unit
    Definition Classes
    Message
  34. def date_=(value: String): Unit
    Definition Classes
    Message
  35. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  36. def equals(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef → Any
  37. def expires: Option[String]
    Definition Classes
    Message
  38. def expires_=(value: Date): Unit
    Definition Classes
    Message
  39. def expires_=(value: String): Unit
    Definition Classes
    Message
  40. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.Throwable])
  41. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  42. def getContentString(): String
    Definition Classes
    Message
  43. def getCookies(): Iterator[Cookie]
    Definition Classes
    Message
  44. final def getInputStream(): InputStream
    Definition Classes
    Message
  45. final def getLength(): Int
    Definition Classes
    Message
  46. final def getReader(): Reader
    Definition Classes
    Message
  47. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  48. def headerMap: HeaderMap
    Definition Classes
    Proxy → Message
  49. final def isChunked: Boolean
    Definition Classes
    Proxy → Message
  50. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  51. final def isRequest: Boolean
    Definition Classes
    Response → Message
  52. def isResponse: Boolean
    Definition Classes
    Message
  53. def isXmlHttpRequest: Boolean
    Definition Classes
    Message
  54. final def keepAlive: Boolean
    Definition Classes
    Message
  55. final def keepAlive(keepAlive: Boolean): EnrichedResponse.this.type
    Definition Classes
    Message
  56. def lastModified: Option[String]
    Definition Classes
    Message
  57. def lastModified_=(value: Date): Unit
    Definition Classes
    Message
  58. def lastModified_=(value: String): Unit
    Definition Classes
    Message
  59. final def length: Int
    Definition Classes
    Message
  60. def location: Option[String]
    Definition Classes
    Response
  61. def location_=(value: String): Unit
    Definition Classes
    Response
  62. def mediaType: Option[String]
    Definition Classes
    Message
  63. def mediaType_=(value: String): Unit
    Definition Classes
    Message
  64. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  65. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  66. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  67. final lazy val reader: Reader[Buf]
    Definition Classes
    Message
  68. def removeCookie(name: String): Unit
    Definition Classes
    Message
  69. def retryAfter: Option[String]
    Definition Classes
    Response
  70. def retryAfter_=(value: Long): Unit
    Definition Classes
    Response
  71. def retryAfter_=(value: String): Unit
    Definition Classes
    Response
  72. def server: Option[String]
    Definition Classes
    Response
  73. def server_=(value: String): Unit
    Definition Classes
    Response
  74. final def setChunked(chunked: Boolean): Unit
    Definition Classes
    Proxy → Message
  75. final def setContentString(value: String): Unit
    Definition Classes
    Message
  76. def setContentType(mediaType: String, charset: String): Unit
    Definition Classes
    Message
  77. def setContentTypeJson(): Unit
    Definition Classes
    Message
  78. final def status: Status
    Definition Classes
    Proxy → Response
  79. final def status(value: Status): EnrichedResponse.this.type
    Definition Classes
    Response
  80. final def statusCode(value: Int): EnrichedResponse.this.type
    Definition Classes
    Response
  81. final def statusCode: Int
    Definition Classes
    Response
  82. final def statusCode_=(value: Int): Unit
    Definition Classes
    Response
  83. final def status_=(value: Status): Unit
    Definition Classes
    Proxy → Response
  84. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  85. def toString(): String
    Definition Classes
    Response → AnyRef → Any
  86. def trailers: HeaderMap
    Definition Classes
    Proxy → Message
  87. final def version: Version
    Definition Classes
    Proxy → Message
  88. final def version(version: Version): EnrichedResponse.this.type
    Definition Classes
    Message
  89. final def version_=(version: Version): Unit
    Definition Classes
    Proxy → Message
  90. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  91. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  92. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()
  93. def withInputStream[T](f: (InputStream) => T): T
    Definition Classes
    Message
  94. final def withOutputStream[T](f: (OutputStream) => T): T
    Definition Classes
    Message
    Annotations
    @throws(classOf[java.lang.IllegalStateException])
  95. final def withReader[T](f: (Reader) => T): T
    Definition Classes
    Message
  96. final def withWriter[T](f: (Writer) => T): T
    Definition Classes
    Message
    Annotations
    @throws(classOf[java.lang.IllegalStateException])
  97. final def write(bytes: Array[Byte]): Unit
    Definition Classes
    Message
    Annotations
    @throws(classOf[java.lang.IllegalStateException])
  98. final def write(buf: Buf): Unit
    Definition Classes
    Message
    Annotations
    @throws(classOf[java.lang.IllegalStateException])
  99. final def write(string: String): Unit
    Definition Classes
    Message
    Annotations
    @throws(classOf[java.lang.IllegalStateException])
  100. final lazy val writer: Writer[Buf]
    Definition Classes
    Message
  101. def wwwAuthenticate: Option[String]
    Definition Classes
    Response
  102. def wwwAuthenticate_=(value: String): Unit
    Definition Classes
    Response

Inherited from ResponseProxy

Inherited from Proxy

Inherited from Response

Inherited from Message

Inherited from AnyRef

Inherited from Any

Ungrouped