include module type of struct include Resto.Query end
Query parameters are the key-value pairs that appear as
?key0=value0&key1=value1&.. at the end of the path in URIs/URLs.
type 'a t = 'a Resto.Query.t
A type for representing query parameters.
type 'a query = 'a t
val empty : unit query
empty is for services that expects no query parameters.
type ('a, 'b) field = ( 'a, 'b ) Resto.Query.field
The type for key-value pairs that constitute a query. The first type parameter is for whole-query store and the second is for the type of value carried by the field.
field ?descr key arg default get is a field for the query parameters, i.e., it describes one key-value pair.
The key is given by
key and the value is parsed as specified in
arg or, if absent from the URI suffix,
get is for retrieving the value from the whole-query store. More on the whole-query store below.
val flag : ?descr:string -> string -> ( 'b -> bool ) -> ( 'b, bool ) field
type ('a, 'b, 'c) open_query = ( 'a, 'b, 'c ) Resto.Query.open_query
Queries are constructed by adding fields to an open query and sealing it into a query. This is done using the functions below. Typically, it is done as follow:
query c |+ field1 |+ field2 |> seal
As the types require, you must provide the correct argument to the successive building steps. Here is an example:
query (fun timeout shade -> (timeout, shade))
|+ field "timeout" Arg.float 10. (fun (timeout, _) -> timeout)
|+ field "shade" Arg.string "fuchsia" (fun (_, shade) -> shade)
query function takes a whole-query store builder (a function that assemble all the fields into a single store of values), and each field takes a function to recover the value from the whole-query store.
val query : 'b -> ( 'a, 'b, 'b ) open_query