Packages

trait Endpoint[A] extends AnyRef

An Endpoint represents the HTTP endpoint.

It is well known and widely adopted in Finagle that "Your Server is a Function" (i.e., Request => Future[Response]). In a REST/HTTP API setting this function may be viewed as Request =1=> (A =2=> Future[B]) =3=> Future[Response], where transformation 1 is a request decoding (deserialization), transformation 2 - is a business logic and transformation 3 is - a response encoding (serialization). The only interesting part here is transformation 2 (i.e., A => Future[B]), which represents an application business.

An Endpoint transformation (map, mapAsync, etc.) encodes the business logic, while the rest of Finch ecosystem takes care about both serialization and deserialization.

A typical way to transform (or map) the Endpoint is to use io.finch.syntax.Mapper:

import io.finch._

case class Foo(i: Int)
case class Bar(s: String)

val foo: Endpoint[Foo] = get("foo") { Ok(Foo(42)) }
val bar: Endpoint[Bar] = get("bar" :: path[String]) { s: String => Ok(Bar(s)) }

Endpoints are also composable in terms of or-else combinator (known as a "space invader" operator :+:) that takes two Endpoints and returns a coproduct Endpoint.

import io.finch._

val foobar: Endpoint[Foo :+: Bar :+: CNil] = foo :+: bar

An Endpoint might be converted into a Finagle Service with Endpoint.toService method so it can be served within Finagle HTTP.

import com.twitter.finagle.Http

Http.server.serve(foobar.toService)
Self Type
Endpoint[A]
Source
Endpoint.scala
Linear Supertypes
Known Subclasses
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Endpoint
  2. AnyRef
  3. Any
Implicitly
  1. by OptionEndpointOps
  2. by HListEndpointOps
  3. by ValueEndpointOps
  4. by any2stringadd
  5. by StringFormat
  6. by Ensuring
  7. by ArrowAssoc
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Abstract Value Members

  1. abstract def apply(input: Input): Result[A]

    Runs this endpoint.

Concrete Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int
    Definition Classes
    AnyRef → Any
  3. def +(other: String): String
    Implicit
    This member is added by an implicit conversion from Endpoint[A] to any2stringadd[Endpoint[A]] performed by method any2stringadd in scala.Predef.
    Definition Classes
    any2stringadd
  4. def ->[B](y: B): (Endpoint[A], B)
    Implicit
    This member is added by an implicit conversion from Endpoint[A] to ArrowAssoc[Endpoint[A]] performed by method ArrowAssoc in scala.Predef. This conversion will take place only if A is Option[Nothing] (A =:= Option[Nothing]).
    Definition Classes
    ArrowAssoc
    Annotations
    @inline()
  5. final def :+:[B](that: Endpoint[B])(implicit a: Adjoin[:+:[B, :+:[A, CNil]]]): Endpoint[shapeless.ops.adjoin.Adjoin.Out]

    Composes this endpoint with another in such a way that coproducts are flattened.

  6. final def ::[B](other: Endpoint[B])(implicit pa: PairAdjoin[B, A]): Endpoint[internal.PairAdjoin.Out]

    Composes this endpoint with the given Endpoint.

  7. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  8. def as[A](implicit gen: Aux[A, A]): Endpoint[A]

    Converts this endpoint to one that returns any type with this shapeless.HList as its representation.

    Converts this endpoint to one that returns any type with this shapeless.HList as its representation.

    Implicit
    This member is added by an implicit conversion from Endpoint[A] to HListEndpointOps[A] performed by method HListEndpointOps in io.finch.Endpoint. This conversion will take place only if A is a subclass of HList (A <: HList).
    Definition Classes
    HListEndpointOps
  9. def as[A](implicit gen: Aux[A, ::[A, HNil]]): Endpoint[A]

    Converts this endpoint to one that returns any type with B :: HNil as its representation.

    Converts this endpoint to one that returns any type with B :: HNil as its representation.

    Implicit
    This member is added by an implicit conversion from Endpoint[A] to ValueEndpointOps[A] performed by method ValueEndpointOps in io.finch.Endpoint.
    Definition Classes
    ValueEndpointOps
  10. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  11. def asTuple(implicit t: Tupler[A]): Endpoint[shapeless.ops.hlist.Tupler.Out]

    Converts this endpoint to one that returns a tuple with the same types as this shapeless.HList.

    Converts this endpoint to one that returns a tuple with the same types as this shapeless.HList.

    Note that this will fail at compile time if this this shapeless.HList contains more than 22 elements.

    Implicit
    This member is added by an implicit conversion from Endpoint[A] to HListEndpointOps[A] performed by method HListEndpointOps in io.finch.Endpoint. This conversion will take place only if A is a subclass of HList (A <: HList).
    Definition Classes
    HListEndpointOps
  12. def clone(): AnyRef
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @native() @throws( ... )
  13. final def coproduct[B >: A](other: Endpoint[B]): Endpoint[B]

    Sequentially composes this endpoint with the given other endpoint.

    Sequentially composes this endpoint with the given other endpoint. The resulting endpoint will succeed if either this or that endpoints are succeed.

    Matching Rules

    - if both endpoints match, the result with a shorter remainder (in terms of consumed route) is picked - if both endpoints don't match, the more specific result (explaining the reason for not matching) is picked

  14. def ensuring(cond: (Endpoint[A]) ⇒ Boolean, msg: ⇒ Any): Endpoint[A]
    Implicit
    This member is added by an implicit conversion from Endpoint[A] to Ensuring[Endpoint[A]] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  15. def ensuring(cond: (Endpoint[A]) ⇒ Boolean): Endpoint[A]
    Implicit
    This member is added by an implicit conversion from Endpoint[A] to Ensuring[Endpoint[A]] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  16. def ensuring(cond: Boolean, msg: ⇒ Any): Endpoint[A]
    Implicit
    This member is added by an implicit conversion from Endpoint[A] to Ensuring[Endpoint[A]] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  17. def ensuring(cond: Boolean): Endpoint[A]
    Implicit
    This member is added by an implicit conversion from Endpoint[A] to Ensuring[Endpoint[A]] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  18. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  19. def equals(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  20. def finalize(): Unit
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  21. def formatted(fmtstr: String): String
    Implicit
    This member is added by an implicit conversion from Endpoint[A] to StringFormat[Endpoint[A]] performed by method StringFormat in scala.Predef.
    Definition Classes
    StringFormat
    Annotations
    @inline()
  22. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  23. final def handle[B >: A](pf: PartialFunction[Throwable, Output[B]]): Endpoint[B]

    Recovers from any exception occurred in this endpoint by creating a new endpoint that will handle any matching throwable from the underlying future.

  24. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  25. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  26. def item: RequestItem

    Request item (part) that's this endpoint work with.

  27. final def liftToTry: Endpoint[Try[A]]

    Lifts this endpoint into one that always succeeds, with Try representing both success and failure cases.

  28. final def map[B](fn: (A) ⇒ B): Endpoint[B]

    Maps this endpoint to the given function A => B.

  29. final def mapAsync[B](fn: (A) ⇒ Future[B]): Endpoint[B]

    Maps this endpoint to the given function A => Future[B].

  30. final def mapOutput[B](fn: (A) ⇒ Output[B]): Endpoint[B]

    Maps this endpoint to the given function A => Output[B].

  31. final def mapOutputAsync[B](fn: (A) ⇒ Future[Output[B]]): Endpoint[B]

    Maps this endpoint to the given function A => Future[Output[B]].

  32. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  33. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  34. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  35. def orElse[B >: A](alternative: ⇒ Option[B]): Endpoint[Option[B]]

    If endpoint is empty it will return provided alternative.

    If endpoint is empty it will return provided alternative.

    Implicit
    This member is added by an implicit conversion from Endpoint[A] to OptionEndpointOps[A] performed by method OptionEndpointOps in io.finch.Endpoint. This conversion will take place only if A is Option[A] (A =:= Option[A]).
    Definition Classes
    OptionEndpointOps
  36. final def product[B](other: Endpoint[B]): Endpoint[(A, B)]

    Returns a product of this and other endpoint.

    Returns a product of this and other endpoint. The resulting endpoint returns a tuple of both values.

    This combinator is an important piece for Finch's error accumulation. In its current form, product will accumulate Finch's own errors (i.e., Errors) into Errors) and will fail-fast with the first non-Finch error (just ordinary Exception) observed.

  37. final def productWith[B, O](other: Endpoint[B])(p: (A, B) ⇒ O): Endpoint[O]

    Returns a product of this and other endpoint.

    Returns a product of this and other endpoint. The resulting endpoint returns a value of resulting type for product function.

  38. final def rescue[B >: A](pf: PartialFunction[Throwable, Future[Output[B]]]): Endpoint[B]

    Recovers from any exception occurred in this endpoint by creating a new endpoint that will handle any matching throwable from the underlying future.

  39. final def should(rule: ValidationRule[A]): Endpoint[A]

    Validates the result of this endpoint using a predefined rule.

    Validates the result of this endpoint using a predefined rule. This method allows for rules to be reused across multiple endpoints.

    rule

    the predefined ValidationRule that will return true if the data is valid

    returns

    an endpoint that will return the value of this reader if it is valid. Otherwise the future fails with an Error.NotValid error.

  40. final def should(rule: String)(predicate: (A) ⇒ Boolean): Endpoint[A]

    Validates the result of this endpoint using a predicate.

    Validates the result of this endpoint using a predicate. The rule is used for error reporting.

    rule

    text describing the rule being validated

    predicate

    returns true if the data is valid

    returns

    an endpoint that will return the value of this reader if it is valid. Otherwise the future fails with an Error.NotValid error.

  41. final def shouldNot(rule: ValidationRule[A]): Endpoint[A]

    Validates the result of this endpoint using a predefined rule.

    Validates the result of this endpoint using a predefined rule. This method allows for rules to be reused across multiple endpoints.

    rule

    the predefined ValidationRule that will return false if the data is valid

    returns

    an endpoint that will return the value of this reader if it is valid. Otherwise the future fails with a Error.NotValid error.

  42. final def shouldNot(rule: String)(predicate: (A) ⇒ Boolean): Endpoint[A]

    Validates the result of this endpoint using a predicate.

    Validates the result of this endpoint using a predicate. The rule is used for error reporting.

    rule

    text describing the rule being validated

    predicate

    returns false if the data is valid

    returns

    an endpoint that will return the value of this reader if it is valid. Otherwise the future fails with a Error.NotValid error.

  43. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  44. final def toService(implicit tr: ToResponse.Aux[A, Json], tre: ToResponse.Aux[Exception, Json]): Service[Request, Response]

    Converts this endpoint to a Finagle service Request => Future[Response] that serves JSON.

    Converts this endpoint to a Finagle service Request => Future[Response] that serves JSON.

    Consider using Bootstrap instead.

  45. final def toServiceAs[CT <: String](implicit tr: ToResponse.Aux[A, CT], tre: ToResponse.Aux[Exception, CT]): Service[Request, Response]

    Converts this endpoint to a Finagle service Request => Future[Response] that serves custom content-type CT.

    Converts this endpoint to a Finagle service Request => Future[Response] that serves custom content-type CT.

    Consider using Bootstrap instead.

  46. def toString(): String
    Definition Classes
    AnyRef → Any
  47. final def transform[B](fn: (Future[Output[A]]) ⇒ Future[Output[B]]): Endpoint[B]

    Transforms this endpoint to the given function Future[Output[A]] => Future[Output[B]].

    Transforms this endpoint to the given function Future[Output[A]] => Future[Output[B]].

    Might be useful to perform some extra action on the underlying Future. For example, time the latency of the given endpoint.

    import io.finch._
    import com.twitter.finagle.stats._
    
    def time[A](stat: Stat, e: Endpoint[A]): Endpoint[A] =
      e.transform(f => Stat.timeFuture(s)(f))
  48. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  49. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  50. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @throws( ... )
  51. def withDefault[B >: A](default: ⇒ B): Endpoint[B]

    If endpoint is empty it will return provided default value.

    If endpoint is empty it will return provided default value.

    Implicit
    This member is added by an implicit conversion from Endpoint[A] to OptionEndpointOps[A] performed by method OptionEndpointOps in io.finch.Endpoint. This conversion will take place only if A is Option[A] (A =:= Option[A]).
    Definition Classes
    OptionEndpointOps
  52. final def withToString(ts: ⇒ String): Endpoint[A]

    Overrides the toString method on this endpoint.

  53. def [B](y: B): (Endpoint[A], B)
    Implicit
    This member is added by an implicit conversion from Endpoint[A] to ArrowAssoc[Endpoint[A]] performed by method ArrowAssoc in scala.Predef. This conversion will take place only if A is Option[Nothing] (A =:= Option[Nothing]).
    Definition Classes
    ArrowAssoc

Shadowed Implicit Value Members

  1. val self: Endpoint[Option[A]]
    Implicit
    This member is added by an implicit conversion from Endpoint[A] to OptionEndpointOps[A] performed by method OptionEndpointOps in io.finch.Endpoint. This conversion will take place only if A is Option[A] (A =:= Option[A]).
    Shadowing
    This implicitly inherited member is ambiguous. One or more implicitly inherited members have similar signatures, so calling this member may produce an ambiguous implicit conversion compiler error.
    To access this member you can use a type ascription:
    (endpoint: OptionEndpointOps[A]).self
    Definition Classes
    OptionEndpointOps
  2. val self: Endpoint[A]
    Implicit
    This member is added by an implicit conversion from Endpoint[A] to HListEndpointOps[A] performed by method HListEndpointOps in io.finch.Endpoint. This conversion will take place only if A is a subclass of HList (A <: HList).
    Shadowing
    This implicitly inherited member is ambiguous. One or more implicitly inherited members have similar signatures, so calling this member may produce an ambiguous implicit conversion compiler error.
    To access this member you can use a type ascription:
    (endpoint: HListEndpointOps[A]).self
    Definition Classes
    HListEndpointOps
  3. val self: Endpoint[A]
    Implicit
    This member is added by an implicit conversion from Endpoint[A] to ValueEndpointOps[A] performed by method ValueEndpointOps in io.finch.Endpoint.
    Shadowing
    This implicitly inherited member is ambiguous. One or more implicitly inherited members have similar signatures, so calling this member may produce an ambiguous implicit conversion compiler error.
    To access this member you can use a type ascription:
    (endpoint: ValueEndpointOps[A]).self
    Definition Classes
    ValueEndpointOps

Inherited from AnyRef

Inherited from Any

Inherited by implicit conversion OptionEndpointOps from Endpoint[A] to OptionEndpointOps[A]

Inherited by implicit conversion HListEndpointOps from Endpoint[A] to HListEndpointOps[A]

Inherited by implicit conversion ValueEndpointOps from Endpoint[A] to ValueEndpointOps[A]

Inherited by implicit conversion any2stringadd from Endpoint[A] to any2stringadd[Endpoint[A]]

Inherited by implicit conversion StringFormat from Endpoint[A] to StringFormat[Endpoint[A]]

Inherited by implicit conversion Ensuring from Endpoint[A] to Ensuring[Endpoint[A]]

Inherited by implicit conversion ArrowAssoc from Endpoint[A] to ArrowAssoc[Endpoint[A]]

Ungrouped