package ocsigen-ppx-rpc

  1. Overview
  2. Docs
This PPX adds a syntax for RPCs for Eliom and Ocsigen Start

Install

Dune Dependency

Authors

Maintainers

Sources

1.0.tar.gz
md5=5d77314a867eeed90a716df837da5ac9
sha512=a4399b48b7ff0fc62a9ec69b0b982350b39cfb5b18d4a13f9aee3e68b78b4a61d65d02d5d8cd08745455a417a44f964c69b6b8709494cf4de57dbf2700cdef68

README.md.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 ppx_deriving

Buildsystem 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) = e

These 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) = e

It 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) () = e

By 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))
OCaml

Innovation. Community. Security.