Skip to content

Commit 6794c0f

Browse files
committed
Graffiti: create + register in two steps everywhere
1 parent 032fc64 commit 6794c0f

File tree

2 files changed

+44
-16
lines changed

2 files changed

+44
-16
lines changed

tutos/7.1/manual/application.wiki

+22-8
Original file line numberDiff line numberDiff line change
@@ -249,9 +249,13 @@ service (now at URL {{{/}}}):
249249

250250
<<code language="ocaml" class="server"|
251251
let%server main_service =
252-
Graffiti_app.create
252+
Eliom_service.create
253253
~path:(Eliom_service.Path [""])
254254
~meth:(Eliom_service.Get Eliom_parameter.unit)
255+
()
256+
257+
let%server () =
258+
Graffiti_app.register ~service:main_service
255259
(fun () () ->
256260
Lwt.return
257261
(html
@@ -376,9 +380,13 @@ open%shared Js_of_ocaml
376380
let%server count = ref 0
377381

378382
let%server main_service =
379-
Graffiti_app.create
383+
Eliom_service.create
380384
~path:(Eliom_service.Path [""])
381385
~meth:(Eliom_service.Get Eliom_parameter.unit)
386+
()
387+
388+
let%server () =
389+
Graffiti_app.register ~service:main_service
382390
(fun () () ->
383391
let c = incr count; !count in
384392
let text = Printf.sprintf "You came %i times to this page" in
@@ -436,9 +444,13 @@ a copy of the {{{<body>}}} element. Hence, the actual page's
436444

437445
<<code language="ocaml" class="server"|
438446
let%server main_service =
439-
Graffiti_app.create
447+
Eliom_service.create
440448
~path:(Eliom_service.Path [""])
441449
~meth:(Eliom_service.Get Eliom_parameter.unit)
450+
()
451+
452+
let%server () =
453+
Graffiti_app.register ~service:main_service
442454
(fun () () ->
443455
let container = body [h1 [txt "Graffiti"]] in
444456
Eliom_service.onload {{
@@ -862,10 +874,8 @@ let%server page () =
862874
Replace {{{main_service}}} by:
863875

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

10411051
<<code language="ocaml" class="server"|
10421052
let%server imageservice =
1043-
Eliom_registration.String.create
1053+
Eliom_service.create
10441054
~path:(Eliom_service.Path ["image"])
10451055
~meth:(Eliom_service.Get Eliom_parameter.unit)
1056+
()
1057+
1058+
let%server () =
1059+
Eliom_registration.String.register ~service:imageservice
10461060
(fun () () -> Lwt.return (image_string (), "image/png"))
10471061
>>
10481062

tutos/dev/manual/application.wiki

+22-8
Original file line numberDiff line numberDiff line change
@@ -249,9 +249,13 @@ service (now at URL {{{/}}}):
249249

250250
<<code language="ocaml" class="server"|
251251
let%server main_service =
252-
Graffiti_app.create
252+
Eliom_service.create
253253
~path:(Eliom_service.Path [""])
254254
~meth:(Eliom_service.Get Eliom_parameter.unit)
255+
()
256+
257+
let%server () =
258+
Graffiti_app.register ~service:main_service
255259
(fun () () ->
256260
Lwt.return
257261
(html
@@ -376,9 +380,13 @@ open%shared Js_of_ocaml
376380
let%server count = ref 0
377381

378382
let%server main_service =
379-
Graffiti_app.create
383+
Eliom_service.create
380384
~path:(Eliom_service.Path [""])
381385
~meth:(Eliom_service.Get Eliom_parameter.unit)
386+
()
387+
388+
let%server () =
389+
Graffiti_app.register ~service:main_service
382390
(fun () () ->
383391
let c = incr count; !count in
384392
let text = Printf.sprintf "You came %i times to this page" in
@@ -436,9 +444,13 @@ a copy of the {{{<body>}}} element. Hence, the actual page's
436444

437445
<<code language="ocaml" class="server"|
438446
let%server main_service =
439-
Graffiti_app.create
447+
Eliom_service.create
440448
~path:(Eliom_service.Path [""])
441449
~meth:(Eliom_service.Get Eliom_parameter.unit)
450+
()
451+
452+
let%server () =
453+
Graffiti_app.register ~service:main_service
442454
(fun () () ->
443455
let container = body [h1 [txt "Graffiti"]] in
444456
Eliom_service.onload {{
@@ -862,10 +874,8 @@ let%server page () =
862874
Replace {{{main_service}}} by:
863875

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

10411051
<<code language="ocaml" class="server"|
10421052
let%server imageservice =
1043-
Eliom_registration.String.create
1053+
Eliom_service.create
10441054
~path:(Eliom_service.Path ["image"])
10451055
~meth:(Eliom_service.Get Eliom_parameter.unit)
1056+
()
1057+
1058+
let%server () =
1059+
Eliom_registration.String.register ~service:imageservice
10461060
(fun () () -> Lwt.return (image_string (), "image/png"))
10471061
>>
10481062

0 commit comments

Comments
 (0)