[ocsigen] Error: Unbound value Eliom_registration.Html.create

Hi !
I am trying to upload a file in an ocsigen web app (working from a working ocsigen-start 2.4.0). I used example code from https://ocsigen.org/eliom/dev/manual/server-links#h5o-11 and http://ocsigen.org/tuto/6.4/manual/how-to-send-file-upload
After a few bug fixes, I end up with :

open%shared Eliom_content.Html
open%shared Eliom_content.Html.F

let%server service = Eliom_service.create
    ~path:(Eliom_service.Path ["upload"])
    ~meth:(Eliom_service.Get Eliom_parameter.unit)

let%client service = ~%service

let%shared upload = Eliom_registration.Html.create
   ~path:(Eliom_service.Path ["upload"])
   ~meth:(Eliom_service.Post (Eliom_parameter.unit,
                              Eliom_parameter.file "file"))
    (fun () file ->
      let to_display =
        (*some code*)
           (head (title (txt "Upload")) [])
           (body [h1 [txt to_display]])))

(*some code*)

And I get following error (running make test.opt):
Error: Unbound value Eliom_registration.Html.create

I find it really surprising as such value is documented at https://ocsigen.org/eliom/dev/api/server/Eliom_registration.Html (I use eliom 6.7) and implicitely there http://ocsigen.org/eliom/dev/api/server/Eliom_registration#2_UsingHTMLwithservices. It also seems to be sourced in my own eliom sources (I found it using grep).
Does someone as a clue on what is going on ?
Thanks for your time :slight_smile:

The function actually exists only on server side, that’s what you get this error message when you compile the client side code.
You can call it in let%server but not in let%client or let%shared.
On the documentation page, you can switch from server to client API.

What we usually do:

  • declare the service in server section with Eliom_service.create
  • declare the client version with let%client upload = ~%upload
  • Then register the service in shared section with My_app.register

Also: If you use Eliom_registration.Html.register, you won’t be able to use the client/server features (like let%client, ~%, [%client ]). If you want them, use your own registration module (My_app in my example), created with functor Eliom_registration.App. See the template application generated by Ocsigen Start for examples.


1 Like