http://ocsigen.org/eliom/manual/server-params#h5o-3은 사용자 정의 유형을 허용하는 GET 서비스의 예를 보여줍니다. 클라이언트 측에서 동일한 유형의 user_type을 사용하여 coservice를 호출하고 싶습니다. 그것이 가능해야한다 것 같다,하지만 난Eliom 클라이언트에서 coservice로 user_type을 전달하려면 어떻게해야합니까?
{shared{
open Eliom_lib
open Eliom_content
open Html5.D
type foo = A | B
let foo_of_string = function "a" -> A | "b" -> B | _ -> raise (Failure "foo_of_string: unsupported foo")
let string_of_foo = function A -> "a" | B -> "b"
}}
let foo_to_div foo : Html5_types.div Html5.elt Lwt.t = match foo with A -> Lwt.return (div [pcdata "aye"]) | B -> Lwt.return (div [pcdata "bee"])
let foo_service =
Eliom_registration.Ocaml.register_post_coservice'
~post_params:Eliom_parameter.(user_type foo_of_string string_of_foo "foo")
(fun() foo -> foo_to_div foo)
{client{
let test() =
Eliom_client.call_ocaml_service ~service:%foo_service() A
}}
(* Boilerplate from eliom-distillery: *)
module Testing_app = Eliom_registration.App
(struct let application_name = "testing" end)
let main_service =
Eliom_service.App.service ~path:[] ~get_params:Eliom_parameter.unit()
let() =
Testing_app.register ~service:main_service
(fun()() -> Lwt.return (Eliom_tools.F.html ~title:"foo"
Html5.F.(body [ pcdata "bar" ])))
나는 또한 server_function를 사용하여 시도,하지만 난을 얻는 방법의 문제로 실행을하려고 할 때
ocsigenserver: main: Exn during page generation: Failure("User service parameters 'foo' type not supported client side.") (sending 500)
를 얻을 수 json으로 다시 돌아 오십시오.
type div_elt = Html5_types.div Eliom_content.Html5.elt
let div_elt_json = Json.t<div_elt>
을하는 것은 나에게 우연히 Error: Unbound module Html5_types.Json_div