let ( let* ) m f = let open Lwt.Infix in m >>= function | Ok x -> f x | Error e -> let msg = Format.asprintf "%a" Git_unix.Store.pp_error e in Views.error_page msg |> Dream_html.respond let ogit_root _req = Views.ogit_root () |> Dream_html.respond let repo_summary req = let repo_path = Dream.param req "repo_name" in let branches = [ "bing"; "bong" ] in let* commits = Git_helpers.recent_commits repo_path 10 in Views.repo_summary repo_path branches commits |> Dream_html.respond let repo_commit req = let repo_path = Dream.param req "repo_name" in let id = match Dream.query req "id" with Some id -> id | None -> "" in let* commit = Git_helpers.get_commit repo_path id in Views.repo_commit repo_path commit |> Dream_html.respond (* let repo_tree req = *) (* let repo_name = Dream.param req "repo_name" in *) (* let path = Git_helpers.full_path repo_name in *) (* let dir_path = Dream.target req in *) (* Views.repo_tree ~repo_path:path dir_path |> Dream_html.respond *) (* let repo_blob req = *) (* let repo_name = Dream.param req "repo_name" in *) (* let path = Git_helpers.full_path repo_name in *) (* let blob_path = Dream.query req "path" |> Option.value ~default:"" in *) (* Views.repo_blob repo_name blob_path |> Dream_html.respond *) let all_handlers = [ Dream.get "/" ogit_root; Dream.scope "/:repo_name" [] [ Dream.get "/" repo_summary; Dream.get "/commit/" repo_commit; (* Dream.get "/tree" repo_tree; *) (* Dream.get "/blob" repo_blob; *) ]; Dream.get "/static/**" (Dream.static "./lib/static"); ]