Install
dune-project
Dependency
Authors
Maintainers
Sources
md5=6c69429c3c7b155c34b343f07e797ce7
sha512=7403540f364667afe5b7942efed8aa67540779809002691ded1d6f8ee51211d25d481c673a9b069f4bab910cf21e5143d96f3c554db1264326394c3518c060ec
doc/README.html
ocsigen-ppx-rpc
This PPX adds a syntax for RPCs for Eliom and Ocsigen Start.
Installation
ocsigen-ppx-rpc can be installed via OPAM:
opam install ocsigen-ppx-rpcBuildsystem integration
With Dune, you should add a preprocess directive to your target:
(executable
(libraries whatever)
(preprocess (pps ocsigen-ppx-rpc))
(name blah))Usage
This PPX let you defined RPCs:
let%rpc f (x1 : t1) ... (xn : tn) = eThese functions are defined server-side and can be used both on the client and on the server.
An additional initial parameter can be used to refer to the current user following Ocsigen Start's convention:
let%rpc f myid (x1 : t1) ... (xn : tn) = e
let%rpc f myid_o (x1 : t1) ... (xn : tn) = eIt is automatically bound: it does not have to provided when invoking the function
Parameters can also be named ~(x : t) or optional ?(x : t option). A unit parameter is allowed at the very end, which can be convenient when using optional parameters:
let%rpc f ?(x1 : t1) ... ~(xn : tn) () = eBy default, this PPX is meant to be used together with Ocsigen Start. So, it automatically inserts Os.Session wrappers. If you want to use it with Eliom but without Ocsigen Start, you can use the option --rpc-raw
(executable
(libraries whatever)
(preprocess (pps ocsigen-ppx-rpc --rpc-raw))
(name blah))The option --rpc-internal is used when compiling Ocsigen Start itself: the wrappers are emitted with the short module names its modules use for each other (Session, Current_user, ...).
Version 2.0 emits the module names introduced by Eliom 13 and Ocsigen Start 9 (Eliom.Client, Os.Session, ...), so it requires Eliom >= 13 in all modes, and Ocsigen Start >= 9 in the default mode. Use ocsigen-ppx-rpc 1.x with older versions.