diff --git a/examples/dune b/examples/dune index 83b0aa84..00ab1a10 100644 --- a/examples/dune +++ b/examples/dune @@ -12,7 +12,7 @@ (executable (name echo) (flags :standard -warn-error -a+8) - (modules echo) + (modules echo vfs) (libraries tiny_httpd tiny_httpd_camlzip)) (rule @@ -30,3 +30,13 @@ (deps test_output.txt) (action (diff test_output.txt.expected test_output.txt))) + +; produce an embedded FS +(rule + (targets vfs.ml) + (deps (source_tree files) (:out test_output.txt.expected)) + (enabled_if (= %{system} "linux")) + (action (run ../src/bin/vfs_pack.exe -o %{targets} + --mirror=files/ + --file=test_out.txt,%{out} + --url=example_dot_com,http://example.com))) diff --git a/examples/echo.ml b/examples/echo.ml index f77bbe72..d2ae7b16 100644 --- a/examples/echo.ml +++ b/examples/echo.ml @@ -107,16 +107,23 @@ let () = S.Response.make_string @@ Ok stats ); + (* VFS *) + Tiny_httpd_dir.add_vfs server + ~config:(Tiny_httpd_dir.config ~download:true + ~dir_behavior:Tiny_httpd_dir.Index_or_lists ()) + ~vfs:Vfs.vfs ~prefix:"vfs"; + (* main page *) S.add_route_handler server S.Route.(return) (fun _req -> let s = "
\n\welcome!\n
endpoints are:\n
/hello/'name' (GET)
/echo/ (GET) echoes back query
/echo/ (GET) echoes back query
/upload/'path' (PUT) to upload a file
/zcat/'path' (GET) to download a file (compressed)
/stats/ (GET) to access statistics
/vfs/ (GET) to access statistics