diff options
author | Marc Coquand <marcc@fastmail.fr> | 2023-12-04 08:06:31 -0600 |
---|---|---|
committer | Marc Coquand <marcc@fastmail.fr> | 2023-12-04 08:06:31 -0600 |
commit | eacb0f2e62b3a713083be9cc15b8af41fac2d6af (patch) | |
tree | 2255733cf314bd0d61467fffde8cea96dfbe0c90 /bin/main.ml | |
parent | 47719821b568704739d42219076c2f7c02bf266b (diff) | |
download | wormhole-eacb0f2e62b3a713083be9cc15b8af41fac2d6af.tar.gz wormhole-eacb0f2e62b3a713083be9cc15b8af41fac2d6af.tar.bz2 wormhole-eacb0f2e62b3a713083be9cc15b8af41fac2d6af.zip |
Add static assets in a single binary
Diffstat (limited to 'bin/main.ml')
-rw-r--r-- | bin/main.ml | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/bin/main.ml b/bin/main.ml index 49469a3..45bd973 100644 --- a/bin/main.ml +++ b/bin/main.ml @@ -67,6 +67,11 @@ let actor_allowlist = "https://graphics.social/users/theohonohan"; ] +let loader _root path _request = + match Assets.read path with + | None -> Dream.empty `Not_Found + | Some asset -> Dream.respond asset + let () = let port = Sys.getenv_opt "PORT" |> Option.map int_of_string @@ -84,7 +89,7 @@ let () = Dream.run ~port ~interface @@ Dream.logger @@ Dream.router [ - Dream.get "/static/**" (Dream.static "./assets"); + Dream.get "/static/**" (Dream.static ~loader ""); Dream.get "/feed.xml" (fun _ -> let posts = Post.get_all () in let maybe_latest_post = Post.latest_post () in |