blob: 95aecd32f690ed38072bbb3da0e91345e228fedf (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
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");
]
|