I encounter some difficulties trying to articulate well client and server code in eliom. I fail registering a Post service to an Eliom app and I do not figure why.
Here some code that I tried, as an example to start the discussion :
open%shared Eliom_content.Html.D let%server service = Eliom_service.create ~path:(Eliom_service.Path ["upload"]) ~meth:(Eliom_service.Get Eliom_parameter.unit) () let%client service = ~%service let%shared name () = "demo-upload" let%shared page_class = "dg-page-demo-upload" let%server upload_service = Eliom_service.create ~path:(Eliom_service.Path ["upload"]) ~meth:(Eliom_service.Post (Eliom_parameter.unit, Eliom_parameter.file "file")) () let%client upload_service = ~%upload_service let%shared () = Docgenius_base.App.register ~service:upload_service (fun () file -> let () = [%server ( some_code_that_does_smth_server_side : unit ) ] in Lwt.return (html (head (title (txt "Upload")) ) (body [h1 [txt "ok"]]))) let%shared page () = let f = (Form.post_form upload_service (fun file -> [p [Form.file_input ~name:file (); br (); Form.input ~input_type:`Submit ~value:"Send" Form.string ]]) ()) in Lwt.return [ h1 [txt "Upload"] ; p [txt "form upload"] ; f ]
Above code is included in ocsigen-start as a demo page, and leads to following error message :
File "demo_upload.eliom", line 28, characters 19-25: Error: Uninterpreted extension 'server'.
I know from https://ocsigen.org/tuto/6.4/manual/misc that I can create a post service with Eliom_service.create and then register an action. This is fine, but I cannot figure out how to notify back easily that a server side computation were fine (the document were properly uploaded), or notify back a result. Maybe should I register an ocaml handler instead of an action for this purpose ?