A symbolic alias for View.
An abstraction that is responsible for decoding the request of general type.
A magnet that wraps a DecodeRequest.
An abstraction that is responsible for decoding the request of type A
.
A type alias for a org.jboss.netty.handler.codec.http.multipart.FileUpload to prevent imports.
Trait with low-priority implicits to avoid conflicts that would arise from adding implicits that would work with any type in the same scope as implicits for concrete types.
Trait with low-priority implicits to avoid conflicts that would arise from adding implicits that would work with any type in the same scope as implicits for concrete types.
Implicits defined in super-types have lower priority than those defined in a sub-type. Therefore we define low- priority implicits here and mix this trait into the package object.
An exception that indicates that a request item could be parsed.
An exception that indicates that a request item could be parsed.
the invalid request item
the type the item should be converted into
the cause of the parsing error
An exception that indicates a required request item (header, param, cookie, body) was missing in the request.
An exception that indicates a required request item (header, param, cookie, body) was missing in the request.
the missing request item
An exception that indicates a broken ValidationRule]] on the request item.
An exception that indicates a broken ValidationRule]] on the request item.
the invalid request item
the rule description
Implicit conversion that adds convenience methods to readers for optional values.
A polymorphic request reader (a reader monad) that reads a Future of A
from the request of type R
.
A base exception of request reader.
An exception that collects multiple request reader errors.
An exception that collects multiple request reader errors.
the errors collected from various request readers
A PRequestReader with request type fixed to HttpRequest.
Adds a ~>
and ~~>
compositors to RequestReader
to compose it with function of one argument.
Adds a ~>
and ~~>
compositors to RequestReader
to compose it with function of one argument.
Adds a ~>
and ~~>
compositors to RequestReader
to compose it with function of two arguments.
Adds a ~>
and ~~>
compositors to RequestReader
to compose it with function of three arguments.
Adds a ~>
and ~~>
compositors to RequestReader
to compose it with function of four arguments.
Adds a ~>
and ~~>
compositors to RequestReader
to compose it with function of five arguments.
Adds a ~>
and ~~>
compositors to RequestReader
to compose it with function of six arguments.
Adds a ~>
and ~~>
compositors to RequestReader
to compose it with function of seven arguments.
Adds a ~>
and ~~>
compositors to RequestReader
to compose it with function of eight arguments.
Implicit conversion that allows to call as[A]
on any RequestReader[Option[String]]
to perform a type conversion
based on an implicit DecodeRequest[A]
which must be in scope.
Implicit conversion that allows to call as[A]
on any RequestReader[Option[String]]
to perform a type conversion
based on an implicit DecodeRequest[A]
which must be in scope.
The resulting reader will fail when the result is non-empty and type conversion fails. It will succeed if the result is empty or type conversion succeeds.
Implicit conversion that allows to call as[A]
on any RequestReader[String]
to perform a type conversion based
on an implicit DecodeRequest[A]
which must be in scope.
Implicit conversion that allows to call as[A]
on any RequestReader[String]
to perform a type conversion based
on an implicit DecodeRequest[A]
which must be in scope.
The resulting reader will fail when type conversion fails.
Implicit conversion that allows to call as[A]
on any RequestReader[Seq[String]]
to perform a type conversion
based on an implicit DecodeRequest[A] which must be in scope.
Implicit conversion that allows to call as[A]
on any RequestReader[Seq[String]]
to perform a type conversion
based on an implicit DecodeRequest[A] which must be in scope.
The resulting reader will fail when the result is non-empty and type conversion fails on one or more of the
elements in the Seq
. It will succeed if the result is empty or type conversion succeeds for all elements.
A reusable validation rule that can be applied to any RequestReader with a matching type.
A sane and safe approach to implicit view A => B
.
A sane and safe approach to implicit view A => B
.
A wrapper for two result values.
Convenience method for creating new DecodeRequest instances.
Convenience methods for creating new reader instances.
Allows the creation of reusable validation rules for RequestReaders.
A companion object for View.
A ValidationRule that makes sure the numeric value is greater than given n
.
A ValidationRule]] that makes sure the numeric value is less than given n
.
A ValidationRule]] that makes sure the string value is longer than n
symbols.
A ValidationRule]] that makes sure the string value is shorter than n
symbols.
A RequestReader that reads a required binary request body, interpreted as a Array[Byte]
, or throws a
NotPresent exception.
A RequestReader that reads a binary request body, interpreted as a Array[Byte]
, into an Option
.
A RequestReader that reads the required request body, interpreted as a String
, or throws a NotPresent
exception.
A RequestReader that reads an optional request body, interpreted as a String
, into an Option
.
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.
the name of the cookie to read
the 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
.
the name of the cookie to read
an Option
that contains a cookie or None if the cookie does not exist on the request.
A DecodeRequest instance for Boolean
.
A DecodeRequest instance for Double
.
A DecodeRequest instance for Float
.
A DecodeRequest instance for Int
.
A DecodeRequest instance for Long
.
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.
the name of the parameter to read
the file
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
.
the name of the parameter to read
an Option
that contains the file or None
is the parameter does not exist on the request.
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.
the header to read
a header
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
.
the header to read
an Option
that contains a header value or None
if the header is not present in the request
Representations for the various types that can be processed with RequestReaders.
Creates a DecodeMagnet from DecodeAnyRequest.
Creates a DecodeMagnet from DecodeAnyRequest.
Creates a DecodeMagnet from DecodeRequest.
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.
the param name to read
a param value
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
.
the param to read
an Option
that contains a param value or None
if the param is empty
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
.
the param to read
a Seq
that contains all the values of multi-value param or an empty seq Nil
if 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.
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.
the param to read
a Seq
that contains all the values of multi-value param
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.
OptionalIntParam("foo").should("be greater than 50") { i: Int => i > 50 }
the underlying function to convert
Implicit conversion that allows the same ValudationRule to be used for required and optional values.
Implicit conversion that allows the same ValudationRule to be used for required and optional values. If the optional value is non-empty, it gets validated (and validation may fail, producing an error), but if it is empty, it is always treated as valid.
the validation rule to adapt for optional values
a new validation rule that applies the specified rule to an optional value in case it is not empty
A RequestReader that reads a binary request body, interpreted as a
Array[Byte]
, into an Option
.
A RequestReader that reads a binary request body, interpreted as a
Array[Byte]
, into an Option
.
(Since version 0.6.0) Use binaryBodyOption instead.
A RequestReader that reads the request body, interpreted as a String
, into an
Option
.
A RequestReader that reads the request body, interpreted as a String
, into an
Option
.
(Since version 0.6.0) Use bodyOption instead.
Creates a RequestReader that reads an optional cookie from the request.
Creates a RequestReader that reads an optional cookie from the request.
the name of the cookie to read
an Option
that contains a cookie or None if the cookie does not exist on the request.
(Since version 0.6.0) Use cookieOption(name) instead.
Creates a RequestReader that reads an optional string header from the
request into an Option
.
Creates a RequestReader that reads an optional string header from the
request into an Option
.
the header to read
an Option
that contains a header value or None
if the header is not present in the request
(Since version 0.6.0) Use headerOption(name) instead.
Creates a RequestReader that reads an optional string param from the
request into an Option
.
Creates a RequestReader that reads an optional string param from the
request into an Option
.
the param to read
an Option
that contains a param value or None
if the param is empty
(Since version 0.6.0) Use paramOption(name) instead
Creates a RequestReader that reads an optional multi-value string param
from the request into a Seq
.
Creates a RequestReader that reads an optional multi-value string param
from the request into a Seq
.
the param to read
a Seq
that contains all the values of multi-value param or an empty seq Nil
if the param is missing
or empty.
(Since version 0.6.0) Use params(name) instead.
A RequestReader that reads an optional binary request body, interpreted as a
Array[Byte]
, or throws a NotPresent exception.
A RequestReader that reads an optional binary request body, interpreted as a
Array[Byte]
, or throws a NotPresent exception.
(Since version 0.6.0) Use binaryBody instead.
A RequestReader that reads the request body, interpreted as a String
, or
throws a NotPresent exception.
A RequestReader that reads the request body, interpreted as a String
, or
throws a NotPresent exception.
(Since version 0.6.0) Use body instead.
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.
the name of the cookie to read
the cookie
(Since version 0.6.0) Use cookie(name) instead.
Creates a RequestReader that reads a required string header from the request or raises a NotPresent exception when the header is missing.
Creates a RequestReader that reads a required string header from the request or raises a NotPresent exception when the header is missing.
the header to read
a header
(Since version 0.6.0) Use header(name) instead.
Creates a RequestReader that reads a required string param from the request or raises a NotPresent exception when the param is missing or empty.
Creates a RequestReader that reads a required string param from the request or raises a NotPresent exception when the param is missing or empty.
the param name to read
a param value
(Since version 0.6.0) Use param(name) instead
Creates a RequestReader that reads a required multi-value string param
from the request into a Seq
or raises a NotPresent exception when the param is
missing or empty.
Creates a RequestReader that reads a required multi-value string param
from the request into a Seq
or raises a NotPresent exception when the param is
missing or empty.
the param to read
a Seq
that contains all the values of multi-value param
(Since version 0.6.0) Use paramsNonEmpty(name) instead.
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 forRequestReader
s composition, the main idea behind it is to use primitive readers (i.e.,RequiredParam
,OptionalParam
) in order to _compose_ them together and _map_ to the application domain data.A
ValidationRule
enables a reusable way of defining a validation rules in the application domain. It might be composed withRequestReader
s using eithershould
orshouldNot
methods and with otherValidationRule
s using logical methodsand
andor
.