(* Copyright (c) 2024-2026 Thomas Gazagnaire Permission to use, copy, modify, and distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. *) (** Git smart-HTTP servers. [Git_server] serves one repository over the git smart protocol, so a [git] client can clone, fetch and push. It adapts the handlers of {!Git_eio.Serve} to {!Respond}, and only frames the HTTP requests and responses: content types and the [info/refs] query. *) val routes : ?context:Git_eio.Repository.ref_context -> ?limits:Git.Serve.Limits.t -> Git_eio.Repository.t -> Respond.route list (** [routes repo] is the smart-HTTP routes of [repo]: [GET /info/refs?service=git-upload-pack|git-receive-pack], [POST /git-upload-pack] and [POST /git-receive-pack], to mount in a {!Respond} server. [limits] defaults to {!Git.Serve.Limits.default} and bounds decoded HTTP bodies and incoming packs. {!run} runs a server of its own. *) val run : ?context:Git_eio.Repository.ref_context -> ?limits:Git.Serve.Limits.t -> ?stop:unit Eio.Promise.t -> ?on_listen:(Eio.Net.Sockaddr.stream -> unit) -> max_connections:int -> mono:_ Eio.Time.Mono.t -> net:_ Eio.Net.t -> addr:Eio.Net.Sockaddr.stream -> Git_eio.Repository.t -> unit (** [run ~stop ~max_connections ~net ~addr repo] serves [repo] over smart HTTP on [addr], on at most [max_connections] connections at once, until [stop] resolves or the fiber is cancelled. [git clone] of the HTTP URL of [addr] then works. [on_listen] is called once with the address the listener is bound to, after the bind and before the first connection is accepted ({!Respond_eio.run}): with port [0] in [addr] it carries the port the system chose. Default: nothing. *)