Library
Module
Module type
Parameter
Class
Class type
type reply = (json, int * string) Result.result
the return value of an JSON-RPC function
module Error : sig ... end
val create : unit -> t
create a JSON-RPC server; the default function will be set to (fun _ -> Error.method_not_found)
, returning this error message as reply to all requests.
add_cb srv ~name cb
add the callback function cb
to the server src
. The function will be called in a JSON-RPC request matches the given function name name
.
set_default src cb
sets the default callback function to cb
in the server srv
. This function is called if no callback function matches the function name in the RPC reuqest.
val remove_cb : name:string -> t -> unit
remove_cb ~name srv
removes the callback function for name name
from the server srv
.
evalj srv json_in
generates a return value for the given JSON-RPC request json_in
for the server srv
. If no answer is to be sent back to the caller, this function will return None
.
val eval : t -> string -> string option
eval srv s
works just like evalj srv json
but will parse the value s
to JSON; it also converts the reply to a string value to be sent back to the caller.