Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Rpc][update doc] apply rpc ppx syntax #23

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,26 +1,20 @@
=How to call a server-side function from client-side?=

It is possible to call server-side functions in client-side code using
the {{{~%}}} syntax. For security reasons, these functions must first
be declared explicitely as "server functions" (with the type of their
argument).
the RPC ppx extension syntax. For security reasons, these functions must be declared with the type of their
argument.

<<code language="ocaml"|
let f x = ...

let%client f_rpc = ~%(Eliom_client.server_function [%derive.json: int] f)
let%rpc f_rpc (x: int) = ...

...

[%client ... f_rpc 4 ... ]
>>

The server-side function ({{{f}}} in the example) needs to return an
The RPC function ({{{f_rpc}}} in the example) needs to return an
Lwt value.

Server functions are just syntactic sugar for pathless services
returning OCaml values.

Note that you need to install {{{ppx_deriving}}}, and load our JSON
{{{ppx_deriving}}} plugin in your project. The plugin is available as
the Ocamlfind package {{{js_of_ocaml.deriving.ppx}}}.
Expand Down