Composes this endpoint with another in such a way that coproducts are flattened.
Composes this endpoint with the given Endpoint.
Composes this endpoint with the given other
endpoint.
Composes this endpoint with the given other
endpoint. The resulting endpoint will succeed
only if both this and that
endpoints succeed.
Maps this endpoint to either A => Output[B]
or A => Output[Future[B]]
.
Recovers from any exception occurred in this endpoint by creating a new endpoint that will handle any matching throwable from the underlying future.
Request item (part) that's this endpoint work with.
Lifts this endpoint into one that always succeeds, with Try representing both success and failure cases.
Maps this endpoint to the given function A => B
.
Maps this endpoint to the given function A => Future[B]
.
Maps this endpoint to the given function A => Output[B]
.
Maps this endpoint to the given function A => Future[Output[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.
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
Recovers from any exception occurred in this endpoint by creating a new endpoint that will handle any matching throwable from the underlying future.
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.
the predefined ValidationRule that will return true if the data is valid
an endpoint that will return the value of this reader if it is valid. Otherwise the future fails with an Error.NotValid error.
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.
text describing the rule being validated
returns true if the data is valid
an endpoint that will return the value of this reader if it is valid. Otherwise the future fails with an Error.NotValid error.
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.
the predefined ValidationRule that will return false if the data is valid
an endpoint that will return the value of this reader if it is valid. Otherwise the future fails with a Error.NotValid error.
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.
text describing the rule being validated
returns false if the data is valid
an endpoint that will return the value of this reader if it is valid. Otherwise the future fails with a Error.NotValid error.
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 custom
content-type CT
.
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))
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.
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 asRequest =1=> (A =2=> Future[B]) =3=> Future[Response]
, where transformation1
is a request decoding (deserialization), transformation2
- is a business logic and transformation3
is - a response encoding (serialization). The only interesting part here is transformation2
(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 Mapper andEndpoint.apply
method, which, depending on the argument type, delegates the map operation to the underlying function.Endpoint
s are also composable in terms of or-else combinator (known as a "space invader" operator:+:
) that takes twoEndpoint
s and returns a coproductEndpoint
.An
Endpoint
might be converted into a Finagle Service withEndpoint.toService
method so it can be served within Finagle HTTP.import com.twitter.finagle.Http Http.server.serve(foobar.toService)