Trait

io.finch.Endpoint

Mappable

Related Doc: package Endpoint

Permalink

trait Mappable[F[_], A] extends Endpoint[F, A]

Enables a very simple syntax allowing to "map" endpoints to arbitrary functions. The types are resolved at compile time and no reflection is used.

For example:

import io.finch._
import io.cats.effect.IO

object Mapping extends Endpoint.Module[IO] {
  def hello = get("hello" :: path[String]) { s: String =>
    Ok(s)
  }
}
Self Type
Mappable[F, A]
Linear Supertypes
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Mappable
  2. Endpoint
  3. AnyRef
  4. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Abstract Value Members

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

    Permalink

    Runs this endpoint.

    Runs this endpoint.

    Definition Classes
    Endpoint

Concrete Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. final def :+:[B](that: Endpoint[F, B])(implicit a: Adjoin[:+:[B, :+:[A, CNil]]], F: MonadError[F, Throwable]): Endpoint[F, shapeless.ops.adjoin.Adjoin.Out]

    Permalink

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

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

    Definition Classes
    Endpoint
  4. final def ::[B](other: Endpoint[F, B])(implicit pa: PairAdjoin[B, A], F: MonadError[F, Throwable]): Endpoint[F, internal.PairAdjoin.Out]

    Permalink

    Composes this endpoint with the given Endpoint.

    Composes this endpoint with the given Endpoint.

    Definition Classes
    Endpoint
  5. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  6. final def apply(mapper: Mapper[F, A]): Endpoint[F, Out]

    Permalink
  7. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  8. final def attempt(implicit F: MonadError[F, Throwable]): Endpoint[F, Either[Throwable, A]]

    Permalink

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

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

    Definition Classes
    Endpoint
  9. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  10. final def compile(implicit F: MonadError[F, Throwable], tr: ToResponse.Aux[F, A, Json], tre: ToResponse.Aux[F, Exception, Json]): Compiled[F]

    Permalink

    Converts this endpoint to Endpoint.Compiled[F] what is efficiently is Kleisli[F, Request, Response] where responses are encoded with JSON encoder.

    Converts this endpoint to Endpoint.Compiled[F] what is efficiently is Kleisli[F, Request, Response] where responses are encoded with JSON encoder.

    Consider using io.finch.Bootstrap instead

    Definition Classes
    Endpoint
  11. final def compileAs[CT <: String](implicit F: MonadError[F, Throwable], tr: ToResponse.Aux[F, A, CT], tre: ToResponse.Aux[F, Exception, CT]): Compiled[F]

    Permalink

    Converts this endpoint to Endpoint.Compiled[F] what is efficiently is Kleisli[F, Request, Response] where responses are encoded with encoder corresponding to CT Content-Type.

    Converts this endpoint to Endpoint.Compiled[F] what is efficiently is Kleisli[F, Request, Response] where responses are encoded with encoder corresponding to CT Content-Type.

    Consider using io.finch.Bootstrap instead

    Definition Classes
    Endpoint
  12. final def coproduct[B >: A](other: Endpoint[F, B]): Endpoint[F, B]

    Permalink

    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

    Definition Classes
    Endpoint
  13. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  14. def equals(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  15. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  16. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  17. final def handle(pf: PartialFunction[Throwable, Output[A]])(implicit F: ApplicativeError[F, Throwable]): Endpoint[F, A]

    Permalink

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

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

    Definition Classes
    Endpoint
  18. def hashCode(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  19. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  20. def item: RequestItem

    Permalink

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

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

    Definition Classes
    Endpoint
  21. final def map[B](fn: (A) ⇒ B)(implicit F: Monad[F]): Endpoint[F, B]

    Permalink

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

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

    Definition Classes
    Endpoint
  22. final def mapAsync[B](fn: (A) ⇒ F[B])(implicit F: Monad[F]): Endpoint[F, B]

    Permalink

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

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

    Definition Classes
    Endpoint
  23. final def mapOutput[B](fn: (A) ⇒ Output[B])(implicit F: MonadError[F, Throwable]): Endpoint[F, B]

    Permalink

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

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

    Definition Classes
    Endpoint
  24. final def mapOutputAsync[B](fn: (A) ⇒ F[Output[B]])(implicit F: Monad[F]): Endpoint[F, B]

    Permalink

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

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

    Definition Classes
    Endpoint
  25. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  26. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  27. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  28. final def product[B](other: Endpoint[F, B])(implicit F: MonadError[F, Throwable]): Endpoint[F, (A, B)]

    Permalink

    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., io.finch.Errors) into io.finch.Errors) and will fail-fast with the first non-Finch error (just ordinary Exception) observed.

    Definition Classes
    Endpoint
  29. final def productWith[B, O](other: Endpoint[F, B])(p: (A, B) ⇒ O)(implicit F: MonadError[F, Throwable]): Endpoint[F, O]

    Permalink

    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.

    Definition Classes
    Endpoint
  30. final def rescue(pf: PartialFunction[Throwable, F[Output[A]]])(implicit F: ApplicativeError[F, Throwable]): Endpoint[F, A]

    Permalink

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

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

    Definition Classes
    Endpoint
  31. final def should(rule: ValidationRule[A])(implicit F: MonadError[F, Throwable]): Endpoint[F, A]

    Permalink

    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.

    Definition Classes
    Endpoint
  32. final def should(rule: String)(predicate: (A) ⇒ Boolean)(implicit F: MonadError[F, Throwable]): Endpoint[F, A]

    Permalink

    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.

    Definition Classes
    Endpoint
  33. final def shouldNot(rule: ValidationRule[A])(implicit F: MonadError[F, Throwable]): Endpoint[F, A]

    Permalink

    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.

    Definition Classes
    Endpoint
  34. final def shouldNot(rule: String)(predicate: (A) ⇒ Boolean)(implicit F: MonadError[F, Throwable]): Endpoint[F, A]

    Permalink

    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.

    Definition Classes
    Endpoint
  35. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  36. final def toService(implicit F: Effect[F], tr: ToResponse.Aux[F, A, Json], tre: ToResponse.Aux[F, Exception, Json]): Service[Request, Response]

    Permalink

    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 io.finch.Bootstrap instead.

    Definition Classes
    Endpoint
  37. final def toServiceAs[CT <: String](implicit F: Effect[F], tr: ToResponse.Aux[F, A, CT], tre: ToResponse.Aux[F, Exception, CT]): Service[Request, Response]

    Permalink

    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 io.finch.Bootstrap instead.

    Definition Classes
    Endpoint
  38. def toString(): String

    Permalink
    Definition Classes
    AnyRef → Any
  39. final def transform[B](fn: (F[A]) ⇒ F[B])(implicit F: Monad[F]): Endpoint[F, B]

    Permalink

    Transform this endpoint to the given function F[A] => F[B]

    Transform this endpoint to the given function F[A] => F[B]

    Definition Classes
    Endpoint
  40. final def transformOutput[B](fn: (F[Output[A]]) ⇒ F[Output[B]]): Endpoint[F, B]

    Permalink

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

    Transforms this endpoint to the given function F[Output[A]] => F[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))
    Definition Classes
    Endpoint
  41. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  42. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  43. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  44. final def withToString(ts: ⇒ String): Endpoint[F, A]

    Permalink

    Overrides the toString method on this endpoint.

    Overrides the toString method on this endpoint.

    Definition Classes
    Endpoint

Deprecated Value Members

  1. final def transformF[B](fn: (F[A]) ⇒ F[B])(implicit F: Monad[F]): Endpoint[F, B]

    Permalink

    Transform this endpoint to the given function F[A] => F[B]

    Transform this endpoint to the given function F[A] => F[B]

    Definition Classes
    Endpoint
    Annotations
    @deprecated
    Deprecated

    (Since version 0.29) Use .transform instead

Inherited from Endpoint[F, A]

Inherited from AnyRef

Inherited from Any

Ungrouped