package ez_api
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>
Easy API library and tools
Install
dune-project
Dependency
Authors
Maintainers
Sources
2.2.0.tar.gz
md5=08f55e6d79d09fd4b14e48981ea89963
sha512=3b00866b03aab19c6f6eac79bd94dfd24bf66829303c03491523476bc9302962f7ff4a820e0b2215ce6362c09ec3da8f65d57908b8f85598154e0f677323843d
doc/src/ez_api.server_utils/cors.ml.html
Source file cors.ml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51open EzAPI let allow_origin_name = "access-control-allow-origin" let allow_headers_name = "access-control-allow-headers" let allow_methods_name = "access-control-allow-methods" let allow_credentials_name = "access-control-allow-credentials" let allow_methods_header l = let meths = StringSet.of_list @@ List.map Meth.to_string l in StringMap.singleton allow_methods_name meths let allow_credentials_header = function | true -> StringMap.singleton allow_credentials_name (StringSet.singleton "true") | _ -> StringMap.empty let insert acc (k, v) = match StringMap.find_opt k acc with | None -> StringMap.add k v acc | Some v2 -> StringMap.add k (StringSet.union v2 v) acc let union s1 s2 = StringMap.union (fun k v1 v2 -> if k = allow_credentials_name && (StringSet.mem "true" v1 || StringSet.mem "true" v2) then Some (StringSet.singleton "true") else if k = allow_credentials_name then None else if k = allow_origin_name && (StringSet.mem "*" v1 || StringSet.mem "*" v2) then Some (StringSet.singleton "*") else Some (StringSet.union v1 v2)) s1 s2 let to_list s = List.filter_map (fun (k, v) -> match StringSet.elements v with | [] -> None | l -> Some (k, String.concat ", " l)) @@ StringMap.bindings s let of_list l = List.fold_left (fun acc (k, v) -> let v = StringSet.of_list @@ List.map String.trim @@ String.split_on_char ',' v in StringMap.add (String.lowercase_ascii k) v acc ) StringMap.empty l type allow_kind = [ `all | `origin | `default | `custom of string list ] let merge_headers_allow_origin ?origin headers kind = match kind with | `none -> headers | `origin -> (match origin with None -> headers | Some o -> headers @ [ allow_origin_name, String.concat "," o ]) | `all | `default -> List.remove_assoc allow_origin_name headers @ [ allow_origin_name, "*" ] | `custom l -> match List.assoc_opt allow_origin_name headers with | None -> headers @ [ allow_origin_name, String.concat "," l ] | Some "*" -> (List.remove_assoc allow_origin_name headers) @ [ allow_origin_name, String.concat "," l ] | Some v -> (List.remove_assoc allow_origin_name headers) @ [ allow_origin_name, String.concat "," (v :: l) ]
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>