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 http://www.w3.org/TR/cors/

    Implements http://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. All

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 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 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
  11. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  12. def clone(): AnyRef
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @native() @throws( ... )
  13. def curried: (Request) ⇒ (Service[Request, Response]) ⇒ Future[Response]
    Definition Classes
    Function2
    Annotations
    @unspecialized()
  14. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  15. def equals(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  16. def finalize(): Unit
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  17. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  18. 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]
  19. 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]
  20. def getOrigin(request: Request): Option[String]
    Attributes
    protected[this]
  21. def handlePreflight(request: Request): Option[Response]

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

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

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

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

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

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

    If each of the header field-names is a simple header and none is Content-Type, than this step may be skipped.

    If each of the header field-names is a simple header and none is Content-Type, than this step may be skipped.

    Add one or more Access-Control-Allow-Headers headers consisting of (a subset of) the list of headers.

    Attributes
    protected[this]
  29. def setMaxAge(response: Response): Response

    Optionally add a single Access-Control-Max-Age header with as value the amount of seconds the user agent is allowed to cache the result of the request.

    Optionally add a single Access-Control-Max-Age header with as value the amount of seconds the user agent is allowed to cache the result of the request.

    Attributes
    protected[this]
  30. def setMethod(response: Response, methods: Seq[String]): Response

    If method is a simple method this step may be skipped.

    If method is a simple method this step may be skipped.

    Add one or more Access-Control-Allow-Methods headers consisting of (a subset of) the list of methods.

    Attributes
    protected[this]
  31. def setOriginAndCredentials(response: Response, origin: String): Response

    If the resource supports credentials add a single Access-Control-Allow-Origin header, with the value of the Origin header as value, and add a single Access-Control-Allow-Credentials header with the case-sensitive string "true" as value.

    If the resource supports credentials add a single Access-Control-Allow-Origin header, with the value of the Origin header as value, and add a single Access-Control-Allow-Credentials header with the case-sensitive string "true" as value.

    Otherwise, add a single Access-Control-Allow-Origin header, with either the value of the Origin header or the string "*" as value.

    n.b. The string "*" cannot be used for a resource that supports credentials.

    Attributes
    protected[this]
  32. 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.

  33. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  34. def toString(): String
    Definition Classes
    Function2 → AnyRef → Any
  35. def tupled: ((Request, Service[Request, Response])) ⇒ Future[Response]
    Definition Classes
    Function2
    Annotations
    @unspecialized()
  36. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  37. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  38. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @throws( ... )
  39. object Preflight
    Attributes
    protected[this]

Inherited from Filter[Request, Response, Request, Response]

Inherited from (Request, Service[Request, Response]) ⇒ Future[Response]

Inherited from AnyRef

Inherited from Any

Ungrouped