Alters any object within a toFuture
method.
Alters any object within a toFuture
method.
an object type
Alters underlying filter within !
methods composing a filter with a given endpoint or withing a next filter.
Alters underlying service within afterThat method composing a service with a given filter.
Alters underlying service within afterThat method composing a service with a given filter.
a input response type
Alters any throwable with a toFutureException
method.
A REST API endpoint that primary defines a route and might be implicitly converted into Finagle service Service[Req, Rep] if there is an implicit view from Req to Request available in the scope.
A REST API endpoint that primary defines a route and might be implicitly converted into Finagle service Service[Req, Rep] if there is an implicit view from Req to Request available in the scope.
the request type
the response type
(Since version 0.8.0) Endpoint is deprecated in favor of coproduct routers
This package introduces types and functions that enable _request processing_ in Finch.
This package introduces types and functions that enable _request processing_ in Finch. The io.finch.request primitives allow both to _read_ the various request items (query string param, header and cookie) using the RequestReader and _validate_ them using the ValidationRule.
The cornerstone abstraction of this package is a RequestReader
, which is responsible for reading any amount of data
from the HTTP request. RequestReader
s might be composed with each other using either monadic API (flatMap
method)
or applicative API (::
method). Regardless the API used for RequestReader
s composition, the main idea behind it
is to use primitive readers (i.e., param
, paramOption
) in order to _compose_ them together and _map_ to
the application domain data.
case class Complex(r: Double, i: Double) val complex: RequestReader[Complex] = ( param("real").as[Double] :: paramOption("imaginary").as[Double].withDefault(0.0) ).as[Complex]
A ValidationRule
enables a reusable way of defining a validation rules in the application domain. It might be
composed with RequestReader
s using either should
or shouldNot
methods and with other ValidationRule
s using
logical methods and
and or
.
case class User(name: String, age: Int) val user: RequestReader[User] = ( param("name").should(beLongerThan(3)) :: param("age").as[Int].should(beGreaterThan(0) and beLessThan(120)) ).as[User]
This package enables a reasonable approach of building HTTP responses using the ResponseBuilder abstraction.
This package enables a reasonable approach of building HTTP responses using the
ResponseBuilder abstraction. The ResponseBuilder
provides an immutable way
of building concrete Response instances by specifying their status,
headers and cookies. There are plenty of predefined builders named by HTTP statuses, i.e., Ok
, Created
,
NotFound
. Thus, the typical use case of the ResponseBuilder
abstraction involves usage of concrete builder
instead of abstract ResponseBuilder
itself.
val ok: Response = Ok("Hello, World!")
In addition to text/plain
responses, the ResponseBuilder
is able to build any response, whose content-type
is
specified by an implicit type-class EncodeResponse instance. In fact, any type
A
may be passed to a RequestReader
if there is a corresponding EncodeRequest[A]
instance available in the
scope.
implicit val encodeBigInt = EncodeResponse[BigInt]("text/plain") { _.toString } val ok: Response = Ok(BigInt(100))
This package contains various of functions and types that enable _router combinators_ in Finch.
This package contains various of functions and types that enable _router combinators_ in Finch. Finch's route.Router is an abstraction that is responsible for routing the HTTP requests using their method and path information.
A companion object for Endpoint
A companion object for Endpoint
(Since version 0.8.0) Endpoint is deprecated in favor of coproduct routers
Allows for the creation of Endpoints without an explicit service.
Allows for the creation of Endpoints without an explicit service.
Endpoint { Method.Get -> Root / "hello" => Ok("world").toFuture }
a future to implicitly convert
a service generated by ignoring the Req and returning the Future[Rep]
(Since version 0.8.0) Endpoint is deprecated in favor of coproduct routers
This is a root package of the Finch library, which provides an immutable layer of functions and types atop of Finagle for writing lightweight HTTP services. It roughly contains three packages: io.finch.route, io.finch.request, io.finch.response.