summaryrefslogtreecommitdiff
path: root/lib/handlers.ml
diff options
context:
space:
mode:
Diffstat (limited to 'lib/handlers.ml')
-rw-r--r--lib/handlers.ml48
1 files changed, 30 insertions, 18 deletions
diff --git a/lib/handlers.ml b/lib/handlers.ml
index 8771f5f..17f3ac0 100644
--- a/lib/handlers.ml
+++ b/lib/handlers.ml
@@ -10,10 +10,11 @@ module Repo = struct
m >>= function
| Ok x -> f x
| Error e ->
- let msg = Format.asprintf "%a" Git_unix.Store.pp_error e in
+ let msg = Format.asprintf "%a" Store.pp_error e in
Views.error_page msg |> Dream_html.respond
- let repo req = Dream.param req "repo_name"
+ let repo req = Dream.param req "repo"
+ let id_of_req req = Dream.param req "id"
let summary req =
let* branches = all_branches (repo req) in
@@ -29,25 +30,36 @@ module Repo = struct
let* commits = recent_commits (repo req) 100 in
Views.Repo.log (repo req) commits |> Dream_html.respond
- let tree req = Views.Repo.tree (repo req) |> Dream_html.respond
+ let tree_head req =
+ Dream.log "Tree head";
+ let* tree = head_tree (repo req) in
+ Views.Repo.tree (repo req) tree |> Dream_html.respond
+
+ let tree_id req =
+ Dream.log "Tree id";
+ let id = id_of_req req in
+ let* tree = tree_of_id (repo req) id in
+ Views.Repo.tree (repo req) tree |> Dream_html.respond
let commit req =
- let id = match Dream.query req "id" with Some id -> id | None -> "" in
- let* commit = of_id (repo req) id in
+ let id = id_of_req req in
+ let* commit = commit_of_id (repo req) id in
Views.Repo.commit (repo req) commit |> Dream_html.respond
end
let all_handlers =
- [
- Dream.get "/" root;
- Dream.scope "/:repo_name" []
- Repo.
- [
- Dream.get "/" summary;
- Dream.get "/refs/" refs;
- Dream.get "/log/" log;
- Dream.get "/tree/" tree;
- Dream.get "/commit/" commit;
- ];
- Dream.get "/static/**" (Dream.static "./lib/static");
- ]
+ Dream.
+ [
+ get "/" root;
+ scope "/:repo" []
+ Repo.
+ [
+ get "/" summary;
+ get "/refs/" refs;
+ get "/log/" log;
+ get "/tree/" tree_head;
+ get "/tree/:id" tree_id;
+ get "/commit/:id" commit;
+ ];
+ get "/static/**" (static "./lib/static");
+ ]
Copyright 2019--2025 Marius PETER