Package

io

finch

Permalink

package finch

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.

Linear Supertypes
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. finch
  2. AnyRef
  3. Any
  1. Hide All
  2. Show all
Visibility
  1. Public
  2. All

Type Members

  1. implicit final class AnyOps[A] extends AnyVal

    Permalink

    Alters any object within a toFuture method.

    Alters any object within a toFuture method.

    A

    an object type

  2. implicit final class FilterOps[ReqIn, ReqOut, RepIn, RepOut] extends AnyVal

    Permalink

    Alters underlying filter within ! methods composing a filter with a given endpoint or withing a next filter.

  3. implicit class ServiceOps[Req, RepIn] extends AnyRef

    Permalink

    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.

    RepIn

    a input response type

  4. implicit final class ThrowableOps extends AnyVal

    Permalink

    Alters any throwable with a toFutureException method.

  5. trait Endpoint[Req, Rep] extends AnyRef

    Permalink

    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.

    Req

    the request type

    Rep

    the response type

    Annotations
    @deprecated
    Deprecated

    (Since version 0.8.0) Endpoint is deprecated in favor of coproduct routers

Value Members

  1. package request

    Permalink

    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. RequestReaders might be composed with each other using either monadic API (flatMap method) or applicative API (:: method). Regardless the API used for RequestReaders 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 RequestReaders using either should or shouldNot methods and with other ValidationRules 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]
  2. package response

    Permalink

    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))
  3. package route

    Permalink

    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.

Deprecated Value Members

  1. object Endpoint

    Permalink

    A companion object for Endpoint

    A companion object for Endpoint

    Annotations
    @deprecated
    Deprecated

    (Since version 0.8.0) Endpoint is deprecated in favor of coproduct routers

  2. implicit def futureToService[Req, Rep](f: Future[Rep]): Service[Req, Rep]

    Permalink

    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
    }
    f

    a future to implicitly convert

    returns

    a service generated by ignoring the Req and returning the Future[Rep]

    Annotations
    @deprecated
    Deprecated

    (Since version 0.8.0) Endpoint is deprecated in favor of coproduct routers

Inherited from AnyRef

Inherited from Any

Ungrouped