package eliom

  1. Overview
  2. Docs
Advanced client/server Web and mobile framework

Install

Dune Dependency

Authors

Maintainers

Sources

11.0.1.tar.gz
md5=3aeeca5f734f8e932b5a00fbfd43bd26
sha512=d92948949c81fe5b84f7d262b72653175d4f69574cbb4f85433f3a40df436e9e78b3f024ebcd98cb0e1c8ec45af0e3f9cd1153187549883f4ddfd32feeee3176

doc/src/eliom.client/eliom_cookies_base.ml.html

Source file eliom_cookies_base.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
# 1 "src/lib/eliom_cookies_base.shared.ml"
[@@@warning "-39"]

type cookie = Ocsigen_cookie_map.cookie =
  | OSet of float option (* exp date *) * string (* value *) * bool (* secure *)
  | OUnset
[@@deriving json]

type cookie_array = (string array * (string * cookie) array) array
[@@deriving json]

[@@@warning "+39"]

(** changes to cookieset_to_json must be completed
    by corresponding changes in cookieset_of_json *)
let cookieset_to_json set =
  let cookietable_array set =
    let add key v l = (key, v) :: l in
    Array.of_list (Ocsigen_cookie_map.Map_inner.fold add set [])
  in
  let add key v l = (Array.of_list key, cookietable_array v) :: l in
  let a = Array.of_list (Ocsigen_cookie_map.Map_path.fold add set []) in
  Deriving_Json.to_string [%json: cookie_array] a

let cookieset_of_json json =
  let array = Deriving_Json.from_string [%json: cookie_array] json in
  let cookietable_array array =
    Array.fold_left
      (fun set (name, cookie) ->
         Ocsigen_cookie_map.Map_inner.add name cookie set)
      Ocsigen_cookie_map.Map_inner.empty array
  in
  Array.fold_left
    (fun set (path, cookietable) ->
       let path = Array.to_list path in
       Ocsigen_cookie_map.Map_path.add path (cookietable_array cookietable) set)
    Ocsigen_cookie_map.empty array
OCaml

Innovation. Community. Security.