package ez_api

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Source file ezWsCommon.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
module type S = sig
  type 'a rp = ('a, string) result Lwt.t

  type 'a action = {
    send : 'a -> unit rp;
    close : int option -> unit rp
  }

  type 'a ws = {
    action : 'a action;
    conn : unit rp
  }
end

module Types = struct
  type 'a rp = ('a, string) result Lwt.t

  type 'a action = {
    send : 'a -> unit rp;
    close : int option -> unit rp
  }

  type 'a ws = {
    action : 'a action;
    conn : unit rp
  }
end

let log ?(action="recv") url =
  Option.iter @@ fun msg -> EzDebug.printf "[>%s %s %s]" msg action url

let res_encoding err ok = Json_encoding.(union [
    case ok Result.to_option Result.ok;
    case err (function Error e -> Some e | _ -> None) Result.error
  ])