resto-directory

A minimal OCaml library for type-safe HTTP/JSON RPCs
IN THIS PACKAGE
type ('o, 'e) t = [
| `Ok of 'o
| `OkChunk of 'o
| `OkStream of 'o stream
| `Created of string option
| `No_content
| `Unauthorized of 'e option
| `Forbidden of 'e option
| `Not_found of 'e option
| `Conflict of 'e option
| `Gone of 'e option
| `Error of 'e option
]

Return type for service handler

Note about the three distinct 200-code constructors:

  • `Ok is for RPCs that return a value that the server should encode as one blob of data. This should be the most common answer for successful returns of simple, reasonably-sized values.
  • `OkChunk is for RPCs that return a value that the server should encode as chunks: multiple blobs, the concatenation of which represents the data. This should be reserved for values that can be fairly large (typically over 4Kb, but this threshold may vary depending on your setup). Data is then transferred using chunked transfer encoding.
  • `OkStream is for RPCs that return a stream of values, not all of which are determined at the time of call.
and 'a stream = {
next : unit -> 'a option Lwt.t;
shutdown : unit -> unit;
}
val return : 'o -> ( 'o, 'e ) t Lwt.t
val return_stream : 'o stream -> ( 'o, 'e ) t Lwt.t