Skip to content

Commit bee734f

Browse files
committed
Bump to new version with post message code sample
1 parent d174f58 commit bee734f

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

_oasis

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
OASISFormat: 0.4
22
Name: nodejs
3-
Version: 0.4
3+
Version: 0.5
44
Synopsis: js_of_ocaml bindings for nodejs
55
Authors: Edgar Aroutiounian <[email protected]>
66
Maintainers: Edgar Aroutiounian <[email protected]>

opam/opam

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
opam-version: "1.2"
22
name: "nodejs"
3-
version: "0.4"
3+
version: "0.5"
44
maintainer: "Edgar Aroutiounian <[email protected]>"
55
authors: [ "Edgar Aroutiounian <[email protected]>" ]
66
license: "BSD-3-clause"
@@ -40,6 +40,28 @@ depexts: [
4040
post-messages: [
4141
"Now you can write OCaml and execute on node."
4242
"Example assuming file name of c.ml:"
43+
"
44+
open Nodejs
45+
46+
let () =
47+
48+
let server =
49+
Http.create_server begin fun incoming response ->
50+
51+
Fs.read_file ~path:\"./client.html\" begin fun err data ->
52+
response#write_head ~status_code:200 [(\"Content-type\", \"text/html\")];
53+
response#end_ ~data:(String data) ()
54+
55+
end
56+
end
57+
in
58+
ignore begin
59+
server#listen ~port:8080 begin fun () ->
60+
61+
Printf.sprintf \"Started Server and Running node: %s\" (new process#version)
62+
|> print_endline
63+
end
64+
end"
4365
"ocamlfind ocamlc c.ml -linkpkg -package nodejs -o T.out"
4466
"js_of_ocaml T.out"
4567
"node T.js"

0 commit comments

Comments
 (0)