io.finch.request

RequestReader

trait RequestReader[A] extends AnyRef

A RequestReader (a reader monad) that reads a Future of A from the request of type R. 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]
Self Type
RequestReader[A]
Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. RequestReader
  2. AnyRef
  3. Any
  1. Hide All
  2. Show all
Learn more about member selection
Visibility
  1. Public
  2. All

Abstract Value Members

  1. abstract def apply(req: Request): Future[A]

    Reads the data from given request req.

    Reads the data from given request req.

    req

    the request to read

  2. abstract def item: RequestItem

    A RequestItem read by this request reader.

Concrete Value Members

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

    Definition Classes
    AnyRef
  2. final def !=(arg0: Any): Boolean

    Definition Classes
    Any
  3. final def ##(): Int

    Definition Classes
    AnyRef → Any
  4. final def ==(arg0: AnyRef): Boolean

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

    Definition Classes
    Any
  6. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  7. def clone(): AnyRef

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  8. def embedFlatMap[B](fn: (A) ⇒ Future[B]): RequestReader[B]

    Flat-maps this request reader to the given function A => Future[B].

  9. final def eq(arg0: AnyRef): Boolean

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

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

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  12. def flatMap[B](fn: (A) ⇒ RequestReader[B]): RequestReader[B]

    Flat-maps this request reader to the given function A => RequestReader[B].

  13. final def getClass(): Class[_]

    Definition Classes
    AnyRef → Any
  14. def hashCode(): Int

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

    Definition Classes
    Any
  16. def lift: RequestReader[Option[A]]

    Lifts this request reader into one that always succeeds, with an empty option representing failure.

  17. def map[B](fn: (A) ⇒ B): RequestReader[B]

    Maps this request reader to the given function A => B.

  18. final def ne(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  19. final def notify(): Unit

    Definition Classes
    AnyRef
  20. final def notifyAll(): Unit

    Definition Classes
    AnyRef
  21. def should(rule: ValidationRule[A]): RequestReader[A]

    Validates the result of this request reader using a predefined rule.

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

    rule

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

    returns

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

  22. def should(rule: String)(predicate: (A) ⇒ Boolean): RequestReader[A]

    Validates the result of this request reader using a predicate.

    Validates the result of this request reader 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

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

  23. def shouldNot(rule: ValidationRule[A]): RequestReader[A]

    Validates the result of this request reader using a predefined rule.

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

    rule

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

    returns

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

  24. def shouldNot(rule: String)(predicate: (A) ⇒ Boolean): RequestReader[A]

    Validates the result of this request reader using a predicate.

    Validates the result of this request reader 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

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

  25. final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
    AnyRef
  26. def toString(): String

    Definition Classes
    AnyRef → Any
  27. final def wait(): Unit

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

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

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  30. def withFilter(p: (A) ⇒ Boolean): RequestReader[A]

    Applies the given filter p to this request reader.

Inherited from AnyRef

Inherited from Any

Ungrouped