Skip to content

Commit

Permalink
Graffiti: create + register in two steps everywhere
Browse files Browse the repository at this point in the history
  • Loading branch information
balat committed Nov 24, 2023
1 parent 032fc64 commit 6794c0f
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 16 deletions.
30 changes: 22 additions & 8 deletions tutos/7.1/manual/application.wiki
Original file line number Diff line number Diff line change
Expand Up @@ -249,9 +249,13 @@ service (now at URL {{{/}}}):

<<code language="ocaml" class="server"|
let%server main_service =
Graffiti_app.create
Eliom_service.create
~path:(Eliom_service.Path [""])
~meth:(Eliom_service.Get Eliom_parameter.unit)
()

let%server () =
Graffiti_app.register ~service:main_service
(fun () () ->
Lwt.return
(html
Expand Down Expand Up @@ -376,9 +380,13 @@ open%shared Js_of_ocaml
let%server count = ref 0

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

let%server () =
Graffiti_app.register ~service:main_service
(fun () () ->
let c = incr count; !count in
let text = Printf.sprintf "You came %i times to this page" in
Expand Down Expand Up @@ -436,9 +444,13 @@ a copy of the {{{<body>}}} element. Hence, the actual page's

<<code language="ocaml" class="server"|
let%server main_service =
Graffiti_app.create
Eliom_service.create
~path:(Eliom_service.Path [""])
~meth:(Eliom_service.Get Eliom_parameter.unit)
()

let%server () =
Graffiti_app.register ~service:main_service
(fun () () ->
let container = body [h1 [txt "Graffiti"]] in
Eliom_service.onload {{
Expand Down Expand Up @@ -862,10 +874,8 @@ let%server page () =
Replace {{{main_service}}} by:

<<code language="ocaml" class="server"|
let%server main_service =
Graffiti_app.create
~path:(Eliom_service.Path [""])
~meth:(Eliom_service.Get Eliom_parameter.unit)
let%server () =
Graffiti_app.register ~service:main_service
(fun () () ->
(* Cf. section "Client side side-effects on the server" *)
let page, cp_sig = page () in
Expand Down Expand Up @@ -1040,9 +1050,13 @@ We also define a service that sends the picture:

<<code language="ocaml" class="server"|
let%server imageservice =
Eliom_registration.String.create
Eliom_service.create
~path:(Eliom_service.Path ["image"])
~meth:(Eliom_service.Get Eliom_parameter.unit)
()

let%server () =
Eliom_registration.String.register ~service:imageservice
(fun () () -> Lwt.return (image_string (), "image/png"))
>>

Expand Down
30 changes: 22 additions & 8 deletions tutos/dev/manual/application.wiki
Original file line number Diff line number Diff line change
Expand Up @@ -249,9 +249,13 @@ service (now at URL {{{/}}}):

<<code language="ocaml" class="server"|
let%server main_service =
Graffiti_app.create
Eliom_service.create
~path:(Eliom_service.Path [""])
~meth:(Eliom_service.Get Eliom_parameter.unit)
()

let%server () =
Graffiti_app.register ~service:main_service
(fun () () ->
Lwt.return
(html
Expand Down Expand Up @@ -376,9 +380,13 @@ open%shared Js_of_ocaml
let%server count = ref 0

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

let%server () =
Graffiti_app.register ~service:main_service
(fun () () ->
let c = incr count; !count in
let text = Printf.sprintf "You came %i times to this page" in
Expand Down Expand Up @@ -436,9 +444,13 @@ a copy of the {{{<body>}}} element. Hence, the actual page's

<<code language="ocaml" class="server"|
let%server main_service =
Graffiti_app.create
Eliom_service.create
~path:(Eliom_service.Path [""])
~meth:(Eliom_service.Get Eliom_parameter.unit)
()

let%server () =
Graffiti_app.register ~service:main_service
(fun () () ->
let container = body [h1 [txt "Graffiti"]] in
Eliom_service.onload {{
Expand Down Expand Up @@ -862,10 +874,8 @@ let%server page () =
Replace {{{main_service}}} by:

<<code language="ocaml" class="server"|
let%server main_service =
Graffiti_app.create
~path:(Eliom_service.Path [""])
~meth:(Eliom_service.Get Eliom_parameter.unit)
let%server () =
Graffiti_app.register ~service:main_service
(fun () () ->
(* Cf. section "Client side side-effects on the server" *)
let page, cp_sig = page () in
Expand Down Expand Up @@ -1040,9 +1050,13 @@ We also define a service that sends the picture:

<<code language="ocaml" class="server"|
let%server imageservice =
Eliom_registration.String.create
Eliom_service.create
~path:(Eliom_service.Path ["image"])
~meth:(Eliom_service.Get Eliom_parameter.unit)
()

let%server () =
Eliom_registration.String.register ~service:imageservice
(fun () () -> Lwt.return (image_string (), "image/png"))
>>

Expand Down

0 comments on commit 6794c0f

Please sign in to comment.