View raw

1 (** Request handlers: the seam between Git data and rendered pages. 2 3 Each handler opens exactly one repository context, reads what its page 4 needs, renders it, and closes the context — so the Git store, resolved 5 metadata and default-branch policy are shared by every operation in a 6 request instead of being reopened per query. 7 8 Errors keep the category {!module:Resolvers} gave them until they reach 9 {!error_response}, which is the single place a category becomes an HTTP 10 status: malformed input is [400], a missing repository or object is [404], 11 and storage failures are [500]. Handlers therefore never choose a status 12 themselves. 13 14 This is also the only layer allowed to touch both configuration and the 15 filesystem; views receive plain values. *) 16 17 val error_response : Resolvers.error -> Dream.response Dream.promise 18 (** Map a resolver failure to the status and wording shown to the reader. *) 19 20 (** Repository-scoped request handlers. *) 21 module Repo : sig 22 val with_repository : 23 Config.t -> 24 string -> 25 (Resolvers.repository -> Repo_view.context -> Dream.response Dream.promise) -> 26 Dream.response Dream.promise 27 (** Open a repository by name, build a view context, run the continuation, 28 then close the repository. Renders an error page on failure. *) 29 end 30 31 val routes : Config.t -> Dream.route list 32 (** The complete set of Dream routes for the application. Requires a loaded 33 configuration to bind repository discovery and rendering. *) 34