Let%rpc does not work in Eliom

Hello
I want to upgrade my program to the new the Eliom syntx let%rpc
I found here in the readme here GitHub - ocsigen/eliom: Multi-tier framework for programming web and mobile applications in OCaml.
but I get:

Error: Uninterpreted extension ‘rpc’.

What is the difference with server_function?

I’m using Eliom 7 with Ocsigen Start 5

Hi Simon,

This syntax is part of an external package ocsigen-ppx-rpc.
Install it with opam if not already installed.
Then add it in your dune file (or to your command-line in Makefile):

(executable
  (libraries whatever)
  (preprocess (pps ocsigen-ppx-rpc))
  (name blah))

Or for people who are not using Ocsigen Start:

(executable
  (libraries whatever)
  (preprocess (pps ocsigen-ppx-rpc --rpc-raw))
  (name blah))

This syntax is just syntactic sugar for server-functions

I would recommend to upgrade to Eliom 10 (there should be very few incompatibilities).

Vincent

Thank you
I replace the server_function by

let%rpc get_data_rpc (bucket : int) : unit Lwt.t =
Os_session.connected_wrapper get_data bucket

Is it ok?

You don’t need the conected_wrapper any more. It is added automatically by the syntax extension (if not used with --rpc-raw). Just define your server side function with let%rpc instead of let and it will be available both on server and client sides.

let%rpc get_data (bucket : int) : unit Lwt.t = ...

If you want to have the information about the current user, call functions like Os_current_user.get_current_user or Os_current_user.Opt.get_current_userid

Thank you. It works
I updated to the last version