summaryrefslogtreecommitdiff
path: root/lib/handlers.ml
diff options
context:
space:
mode:
Diffstat (limited to 'lib/handlers.ml')
-rw-r--r--lib/handlers.ml24
1 files changed, 17 insertions, 7 deletions
diff --git a/lib/handlers.ml b/lib/handlers.ml
index f4a7d7b..95aecd3 100644
--- a/lib/handlers.ml
+++ b/lib/handlers.ml
@@ -1,15 +1,24 @@
-open Lwt.Syntax
+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 = Git_helpers.all_branches repo_path
- and* commits = Git_helpers.latest_commits repo_path 10 in
- match (branches, commits) with
- | Ok branches, Ok commits ->
- Views.repo_summary repo_path ~branches ~commits |> Dream_html.respond
- | Error msg, _ | _, Error msg -> Views.error_page msg |> Dream_html.respond
+ 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 *)
@@ -29,6 +38,7 @@ let all_handlers =
Dream.scope "/:repo_name" []
[
Dream.get "/" repo_summary;
+ Dream.get "/commit/" repo_commit;
(* Dream.get "/tree" repo_tree; *)
(* Dream.get "/blob" repo_blob; *)
];
Copyright 2019--2025 Marius PETER