Materials for the LambdaNantes 4 workshop: An Introduction to Unikernels with OCaml!
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

A first "concrete webserver"

xvw e35d2e45 434af8b4

+11 -6
+1 -1
unikernels/web_html_server/dune
··· 28 28 (targets documents.ml) 29 29 (deps index.html style.css) 30 30 (action 31 - (run mcrunch --list --file index:index.html --file style:style.css -o documents.ml))) 31 + (run mcrunch --list --file index_html:index.html --file style_css:style.css -o documents.ml)))
+2 -1
unikernels/web_html_server/index.html
··· 11 11 <div> 12 12 <h1>Hello, Lambda Nantes</h1> 13 13 <p> 14 - This an operating system dedicated to this page! 14 + This an <strong>operating system</strong> dedicated to this 15 + page! 15 16 </p> 16 17 </div> 17 18 </main>
+8 -4
unikernels/web_html_server/main.ml
··· 12 12 let clean_rng rng () = Mirage_crypto_rng_mkernel.kill rng 13 13 let clean_stack stack () = Mnet.kill stack 14 14 15 - let index req _server () = 15 + (* Respond the given file [f] *) 16 + let respond_file f req _server () = 16 17 let open Vifu.Response.Syntax in 17 - let source = Flux.Source.list Documents.index in 18 - let* () = Vifu.Response.with_text req "Hello, Lambda Nantes!\n" in 18 + let source = Flux.Source.list f in 19 + let* () = Vifu.Response.with_source req source in 19 20 Vifu.Response.respond `OK 20 21 ;; 21 22 22 23 (* Route of the application *) 23 24 let routes = 24 25 let open Vifu.Uri in 25 - Vifu.Route.[ get (rel /?? any) --> handler ] 26 + Vifu.Route. 27 + [ get (rel /?? any) --> respond_file Documents.index_html 28 + ; get (rel / "style.css" /?? any) --> respond_file Documents.style_css 29 + ] 26 30 ;; 27 31 28 32 (* Main program *)