+let query_kind_of_req (req: Http_types.request) =
+ match req#path with
+ | "/match" -> "Match"
+ | "/hint" -> "Hint"
+ | "/locate" -> "Locate"
+ | "/elim" -> "Elim"
+ | _ -> ""
+
+ (* given a uri with a query part in input try to find in it a string
+ * "¶m_name=..." (where param_name is given). If found its value will be
+ * set to param_value. If not, a trailing "¶m_name=param_value" (where
+ * both are given) is added to the input string *)
+let patch_param param_name param_value url =
+ let rex = Pcre.regexp (sprintf "&%s=[^&]*" (Pcre.quote param_name)) in
+ if Pcre.pmatch ~rex url then
+ Pcre.replace ~rex ~templ:(sprintf "%s=%s" param_name param_value) url
+ else
+ sprintf "%s&%s=%s" url param_name param_value
+