package equinoxe

  1. Overview
  2. Docs

The S module gathers all the methods you need to be able to execute HTTP requests to contact an API server. It must send application/json request.

type t

t contains the information about the token you are using to identify the client and the address of the server (URL).

val token : t -> string

token t returns the token associated with the data structure.

val address : t -> string

address t returns the address of the server.

val create : address:string -> ?token:[ `Default | `Str of string | `Path of string ] -> unit -> t

create ~address ~token () builds the configuration you are going to use to execute the request. If token is not provided, it will extract the token from the environment variable EQUINOXE_TOKEN.

val get : t -> path:string -> unit -> Json.t Lwt.t

get t ~path () executes a request to the server as a GET call and, returns the result as Json.t.

val post : t -> path:string -> Json.t -> Json.t Lwt.t

post t ~path json executes a request to the server as a POST call using Json.t to describe the request. It returns the result as Json.t.

val put : t -> path:string -> Json.t -> Json.t Lwt.t

put t ~path json executes a request to the server as a PUT call using Json.t to describe the request. It returns the result as Json.t.

val delete : t -> path:string -> unit -> Json.t Lwt.t

delete t ~path () executes a request to the server as a DELETE call and, returns the result as Json.t.

val run : Json.t Lwt.t -> Json.t

run json unwraps the API request and gives a JSON.

OCaml

Innovation. Community. Security.