dream-accept

Accept headers parsing for Dream
README

Accept headers parsing for Dream.

Usage

Here is an example of a Dream application that reads the accepted media types and the accepted languages, and generates an HTML pages with the values.

let () =
  Dream.run
  @@ Dream.logger
  @@ Dream.router
       [ Dream.get "/" (fun req ->
             let media_type =
               match Dream_accept.accepted_media_types req |> List.hd with
               | Dream_accept.Media_type (s, sub) ->
                 Printf.sprintf "%s/%s" s sub
               | Dream_accept.Any_media_subtype s ->
                 s
               | Dream_accept.Any ->
                 "*"
             in
             let language =
               match Dream_accept.accepted_languages req |> List.hd with
               | Dream_accept.Language s ->
                 s
               | Dream_accept.Any ->
                 "*"
             in
             Dream.html
               (Printf.sprintf
                  "Media type: %s<br>Language: %s"
                  media_type
                  language))
       ]
Install
Maintainers
Sources
dream-accept-0.1.0.tbz
sha256=79634bbf78fb90f70c54c9a5903b897b84d837281dd6e90f26db6e3123057010
sha512=13e4dc9e823e5d16c63bbb9afc14e1832e66de9b354d7608540e65ff8cb4297bd88862d13f64dfad6eebd21b9969f02ebf381c972cb43c44932822cf8dce50b6
Dependencies
odoc
with-doc
dream
>= "1.0.0~alpha3"
ocaml
>= "4.08.0"
dune
>= "2.9"
Reverse Dependencies