Packages

  • package root
    Definition Classes
    root
  • package com
    Definition Classes
    root
  • package twitter

    Start with com.twitter.finagle.

    Definition Classes
    com
  • package finagle

    Finagle is an extensible RPC system.

    Finagle is an extensible RPC system.

    Services are represented by class com.twitter.finagle.Service. Clients make use of com.twitter.finagle.Service objects while servers implement them.

    Finagle contains a number of protocol implementations; each of these implement Client and/or com.twitter.finagle.Server. For example, Finagle's HTTP implementation, com.twitter.finagle.Http (in package finagle-http), exposes both.

    Thus a simple HTTP server is built like this:

    import com.twitter.finagle.{Http, Service}
    import com.twitter.finagle.http.{Request, Response}
    import com.twitter.util.{Await, Future}
    
    val service = new Service[Request, Response] {
      def apply(req: Request): Future[Response] =
        Future.value(Response())
    }
    val server = Http.server.serve(":8080", service)
    Await.ready(server)

    We first define a service to which requests are dispatched. In this case, the service returns immediately with a HTTP 200 OK response, and with no content.

    This service is then served via the Http protocol on TCP port 8080. Finally we wait for the server to stop serving.

    We can now query our web server:

    % curl -D - localhost:8080
    HTTP/1.1 200 OK

    Building an HTTP client is also simple. (Note that type annotations are added for illustration.)

    import com.twitter.finagle.{Http, Service}
    import com.twitter.finagle.http.{Request, Response}
    import com.twitter.util.{Future, Return, Throw}
    
    val client: Service[Request, Response] = Http.client.newService("localhost:8080")
    val f: Future[Response] = client(Request()).respond {
      case Return(rep) =>
        printf("Got HTTP response %s\n", rep)
      case Throw(exc) =>
        printf("Got error %s\n", exc)
    }

    Http.client.newService("localhost:8080") constructs a new com.twitter.finagle.Service instance connected to localhost TCP port 8080. We then issue a HTTP/1.1 GET request to URI "/". The service returns a com.twitter.util.Future representing the result of the operation. We listen to this future, printing an appropriate message when the response arrives.

    The Finagle homepage contains useful documentation and resources for using Finagle.

    Definition Classes
    twitter
  • package http
    Definition Classes
    finagle
  • package filter
    Definition Classes
    http
  • object Cors

    Implements https://www.w3.org/TR/cors/

    Implements https://www.w3.org/TR/cors/

    Definition Classes
    filter
  • HttpFilter
  • Policy

class HttpFilter extends Filter[Request, Response, Request, Response]

An HTTP filter that handles preflight (OPTIONS) requests and sets CORS response headers as described in the W3C CORS spec.

Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. HttpFilter
  2. Filter
  3. Function2
  4. AnyRef
  5. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Instance Constructors

  1. new HttpFilter(policy: Policy)

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 addExposedHeaders(response: Response): Response

    If the list of exposed headers is not empty add one or more Access-Control-Expose- Headers headers, with as values the header field names given in the list of exposed headers.

    If the list of exposed headers is not empty add one or more Access-Control-Expose- Headers headers, with as values the header field names given in the list of exposed headers.

    By not adding the appropriate headers resource can also clear the preflight result cache of all entries where origin is a case-sensitive match for the value of the Origin header and url is a case-sensitive match for the URL of the resource.

    Attributes
    protected[this]
  5. def agnosticAndThen(next: TypeAgnostic): Filter[Request, Response, Request, Response]

    Convert the Filter.TypeAgnostic filter to a Filter and chain it with andThen.

    Convert the Filter.TypeAgnostic filter to a Filter and chain it with andThen.

    Definition Classes
    Filter
  6. def andThen(factory: ServiceFactory[Request, Response]): ServiceFactory[Request, Response]

    Terminates a filter chain in a ServiceFactory.

    Terminates a filter chain in a ServiceFactory. For example,

    myFilter.andThen(myServiceFactory)
    factory

    a service factory that takes the output request type and the input response type.

    Definition Classes
    Filter
  7. def andThen(service: Service[Request, Response]): Service[Request, Response]

    Terminates a filter chain in a Service.

    Terminates a filter chain in a Service. For example,

    myFilter.andThen(myService)
    service

    a service that takes the output request type and the input response type.

    Definition Classes
    Filter
  8. def andThen[Req2, Rep2](next: Filter[Request, Response, Req2, Rep2]): Filter[Request, Response, Req2, Rep2]

    Chains a series of filters together:

    Chains a series of filters together:

    myModularService = handleExceptions.andThen(thrift2Pojo.andThen(parseString))
    next

    another filter to follow after this one

    Definition Classes
    Filter
    Note

    synchronously thrown exceptions in the underlying service are automatically lifted into Future.exception.

  9. def andThenIf[Req2 >: Request, Rep2 <: Response](condAndFilter: (Boolean, Filter[Request, Response, Req2, Rep2])): Filter[Request, Response, Req2, Rep2]

    Conditionally propagates requests down the filter chain.

    Conditionally propagates requests down the filter chain. This may be useful if you are statically wiring together filter chains based on a configuration file, for instance.

    condAndFilter

    a tuple of boolean and filter.

    Definition Classes
    Filter
  10. def andThenIf[Req2 >: Request, Rep2 <: Response](conditional: Boolean, filter: Filter[Request, Response, Req2, Rep2]): Filter[Request, Response, Req2, Rep2]

    Conditionally propagates requests down the filter chain.

    Conditionally propagates requests down the filter chain. This may be useful if you are statically wiring together filter chains based on a configuration file, for instance.

    conditional

    a boolean value indicating whether the filter should be included in the filter chain.

    filter

    the filter to be conditionally included.

    Definition Classes
    Filter
  11. def apply(request: Request, service: Service[Request, Response]): Future[Response]

    Fully handle preflight requests.

    Fully handle preflight requests. If a preflight request is deemed to be unacceptable, a 200 OK response is served without CORS headers.

    Adds CORS response headers onto all non-preflight requests that have the 'Origin' header set to a value that is allowed by the Policy.

    request

    the input request type

    service

    a service that takes the output request type and the input response type

    Definition Classes
    HttpFilterFilter → Function2
  12. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  13. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @native()
  14. def curried: (Request) => (Service[Request, Response]) => Future[Response]
    Definition Classes
    Function2
    Annotations
    @unspecialized()
  15. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  16. def equals(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef → Any
  17. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.Throwable])
  18. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  19. def getHeaders(request: Request): Seq[String]

    Let header field-names be the values as result of parsing the Access-Control-Request-Headers headers.

    Let header field-names be the values as result of parsing the Access-Control-Request-Headers headers. If there are no Access-Control-Request-Headers headers let header field-names be the empty list.

    Attributes
    protected[this]
  20. def getMethod(request: Request): Option[String]

    Let method be the value as result of parsing the Access-Control-Request-Method header.

    Let method be the value as result of parsing the Access-Control-Request-Method header.

    Attributes
    protected[this]
  21. def getOrigin(request: Request): Option[String]
    Attributes
    protected[this]
  22. def handlePreflight(request: Request): Option[Response]

    https://www.w3.org/TR/cors/#resource-preflight-requests

    https://www.w3.org/TR/cors/#resource-preflight-requests

    Attributes
    protected[this]
  23. def handleSimple(request: Request, response: Response): Response

    https://www.w3.org/TR/cors/#resource-requests

    https://www.w3.org/TR/cors/#resource-requests

    Attributes
    protected[this]
  24. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  25. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  26. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  27. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  28. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  29. def setVary(response: Response): Response

    Resources that wish to enable themselves to be shared with multiple Origins but do not respond uniformly with "*" must in practice generate the Access-Control-Allow-Origin header dynamically in response to every request they wish to allow.

    Resources that wish to enable themselves to be shared with multiple Origins but do not respond uniformly with "*" must in practice generate the Access-Control-Allow-Origin header dynamically in response to every request they wish to allow. As a consequence, authors of such resources should send a Vary: Origin HTTP header or provide other appropriate control directives to prevent caching of such responses, which may be inaccurate if re-used across- origins.

  30. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  31. def toString(): String
    Definition Classes
    Filter → Function2 → AnyRef → Any
  32. def tupled: ((Request, Service[Request, Response])) => Future[Response]
    Definition Classes
    Function2
    Annotations
    @unspecialized()
  33. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  34. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  35. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()
  36. object Preflight
    Attributes
    protected[this]

Inherited from (Request, Service[Request, Response]) => Future[Response]

Inherited from AnyRef

Inherited from Any

Ungrouped