123456789101112131415161718192021222324252627282930313233343536373839404142(* This file is part of Dream, released under the MIT license. See LICENSE.md
for details, or visit https://github.com/aantron/dream.
Copyright 2021 Anton Bachin *)(* TODO Long-term, query string handler is likely to become part of the
router. *)moduleFormats=Dream_pure.FormatsmoduleMessage=Dream_pure.Message(* TODO Actually cache the result of parsing the query string. *)(* let query_variable : (string * string) list Dream.local =
Dream.new_local
~name:"dream.query"
~show_value:(fun query ->
query
|> List.map (fun (name, value) -> Printf.sprintf "%s=%s" name value)
|> String.concat ", ") *)letall_queriesrequest=Message.targetrequest|>Formats.split_target|>snd|>Formats.from_form_urlencodedletqueryrequestname=List.assoc_optname(all_queriesrequest)letqueriesrequestname=all_queriesrequest|>List.fold_left(funaccumulator(name',value)->ifname'=namethenvalue::accumulatorelseaccumulator)[]|>List.rev