io.finch

request

package request

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.

Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. request
  2. AnyRef
  3. Any
  1. Hide All
  2. Show all
Learn more about member selection
Visibility
  1. Public
  2. All

Type Members

  1. trait DecodeAnyRequest extends AnyRef

    An abstraction that is responsible for decoding the request of general type.

  2. trait DecodeRequest[A] extends AnyRef

    An abstraction that is responsible for decoding the request of type A.

  3. case class NotParsed(item: RequestItem, targetType: ClassTag[_], cause: Throwable) extends RequestError with Product with Serializable

    An exception that indicates that a request item could be parsed.

  4. case class NotPresent(item: RequestItem) extends RequestError with Product with Serializable

    An exception that indicates a required request item (header, param, cookie, body) was missing in the request.

  5. case class NotValid(item: RequestItem, rule: String) extends RequestError with Product with Serializable

    An exception that indicates a broken ValidationRule]] on the request item.

  6. class RequestError extends Exception

    A base exception of request reader.

  7. case class RequestErrors(errors: Seq[Throwable]) extends RequestError with Product with Serializable

    An exception that collects multiple request reader errors.

  8. trait RequestReader[A] extends AnyRef

    A RequestReader (a reader monad) that reads a Future of A from the request of type R.

  9. trait ValidationRule[A] extends AnyRef

    A ValidationRule enables a reusable way of defining a validation rules in the application domain.

Value Members

  1. object DecodeRequest

  2. object RequestReader

    Convenience methods for creating new reader instances.

  3. object ValidationRule

    Allows the creation of reusable validation rules for RequestReaders.

  4. def beGreaterThan[A](n: A)(implicit ev: Numeric[A]): ValidationRule[A]

    A ValidationRule that makes sure the numeric value is greater than given n.

  5. def beLessThan[A](n: A)(implicit ev: Numeric[A]): ValidationRule[A]

    A ValidationRule]] that makes sure the numeric value is less than given n.

  6. def beLongerThan(n: Int): ValidationRule[String]

    A ValidationRule]] that makes sure the string value is longer than n symbols.

  7. def beShorterThan(n: Int): ValidationRule[String]

    A ValidationRule]] that makes sure the string value is shorter than n symbols.

  8. val binaryBody: RequestReader[Array[Byte]]

    A RequestReader that reads a required binary request body, interpreted as a Array[Byte], or throws a NotPresent exception.

  9. val binaryBodyOption: RequestReader[Option[Array[Byte]]]

    A RequestReader that reads a binary request body, interpreted as a Array[Byte], into an Option.

  10. val body: RequestReader[String]

    A RequestReader that reads the required request body, interpreted as a String, or throws a NotPresent exception.

  11. val bodyOption: RequestReader[Option[String]]

    A RequestReader that reads an optional request body, interpreted as a String, into an Option.

  12. def cookie(name: String): RequestReader[Cookie]

    Creates a RequestReader that reads a required cookie from the request or raises a NotPresent exception when the cookie is missing.

    Creates a RequestReader that reads a required cookie from the request or raises a NotPresent exception when the cookie is missing.

    name

    the name of the cookie to read

    returns

    the cookie

  13. def cookieOption(name: String): RequestReader[Option[Cookie]]

    Creates a RequestReader that reads an optional HTTP cookie from the request into an Option.

    Creates a RequestReader that reads an optional HTTP cookie from the request into an Option.

    name

    the name of the cookie to read

    returns

    an Option that contains a cookie or None if the cookie does not exist on the request.

  14. def fileUpload(name: String): RequestReader[FileUpload]

    Creates a RequestReader that reads a required file upload from a multipart/form-data request.

    Creates a RequestReader that reads a required file upload from a multipart/form-data request.

    name

    the name of the parameter to read

    returns

    the file

  15. def fileUploadOption(name: String): RequestReader[Option[FileUpload]]

    Creates a RequestReader that reads an optional file upload from a multipart/form-data request into an Option.

    Creates a RequestReader that reads an optional file upload from a multipart/form-data request into an Option.

    name

    the name of the parameter to read

    returns

    an Option that contains the file or None is the parameter does not exist on the request.

  16. def header(name: String): RequestReader[String]

    Creates a RequestReader that reads a required HTTP header name from the request or raises a NotPresent exception when the header is missing.

    Creates a RequestReader that reads a required HTTP header name from the request or raises a NotPresent exception when the header is missing.

    name

    the header to read

    returns

    a header

  17. def headerOption(name: String): RequestReader[Option[String]]

    Creates a RequestReader that reads an optional HTTP header name from the request into an Option.

    Creates a RequestReader that reads an optional HTTP header name from the request into an Option.

    name

    the header to read

    returns

    an Option that contains a header value or None if the header is not present in the request

  18. object items

    Representations for the various types that can be processed with RequestReaders.

  19. def param(name: String): RequestReader[String]

    Creates a RequestReader that reads a required query-string param name from the request or raises a NotPresent exception when the param is missing; a NotValid exception is the param is empty.

    Creates a RequestReader that reads a required query-string param name from the request or raises a NotPresent exception when the param is missing; a NotValid exception is the param is empty.

    name

    the param name to read

    returns

    a param value

  20. def paramOption(name: String): RequestReader[Option[String]]

    Creates a RequestReader that reads an optional query-string param name from the request into an Option.

    Creates a RequestReader that reads an optional query-string param name from the request into an Option.

    name

    the param to read

    returns

    an Option that contains a param value or None if the param is empty

  21. def params(name: String): RequestReader[Seq[String]]

    Creates a RequestReader that reads an optional (in a meaning that a resulting Seq may be empty) multi-value query-string param name from the request into a Seq.

    Creates a RequestReader that reads an optional (in a meaning that a resulting Seq may be empty) multi-value query-string param name from the request into a Seq.

    name

    the param to read

    returns

    a Seq that contains all the values of multi-value param or an empty seq Nil if the params are missing or empty.

  22. def paramsNonEmpty(name: String): RequestReader[Seq[String]]

    Creates a RequestReader that reads a required (in a meaning that a resulting Seq will have at least one element) multi-value query-string param name from the request into a Seq or raises a NotPresent exception when the params are missing or empty.

    Creates a RequestReader that reads a required (in a meaning that a resulting Seq will have at least one element) multi-value query-string param name from the request into a Seq or raises a NotPresent exception when the params are missing or empty.

    name

    the param to read

    returns

    a Seq that contains all the values of multi-value param

  23. implicit def toOptionalInlineRule[A](fn: (A) ⇒ Boolean): (Option[A]) ⇒ Boolean

    Implicit conversion that allows the same inline rules to be used for required and optional values.

    Implicit conversion that allows the same inline rules to be used for required and optional values. If the optional value is non-empty, it gets validated (and validation may fail, producing error), but if it is empty, it is always treated as valid.

    In order to help the compiler determine the case when inline rule should be converted, the type of the validated value should be specified explicitly.

    paramOption("foo").should("be greater than 50") { i: Int => i > 50 }
    fn

    the underlying function to convert

Inherited from AnyRef

Inherited from Any

Ungrouped