Documentation ¶
Overview ¶
Package dgit provides the DGit http.Handler and its helpers.
DGit is a fast, template-driven Git repository viewer written in pure Go. Being written in pure Go, it is possible to statically-link the resulting command-line interface with all of its dependencies, including templates and static files. When this is achieved, its only external requirements are the Git repositories themselves. This makes DGit suitable for dropping into a chroot or other restricted environment.
To use, initialize DGit with a config.Config object specifying, among other things, an io/fs.FS containing your HTML templates, drop this Handler into your site's http.ServeMux and start viewing Git repositories.
The DGit handler supports the "dumb" Git HTTP transfer protocol, so read-only repository operations, such as cloning and fetching, are supported.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DGit ¶
DGit is an http.Handler and can therefore be dropped into an http.ServeMux. It serves read-only pages with Git repository information in the following manner, where / is the root of the DGit http.Handler:
- Navigating to / serves a list of Git repositories available for viewing.
- Navigating to /{repo} serves the tree of the HEAD ref for the of {repo}. If the repository contains a README file, it's raw contents are displayed below the commit tree.
- Navigating to /{repo}/-/refs displays a list of branches and tags for repository {repo}.
- Navigating to /{repo}/-/tree/{rev}/{path} displays the tree for {rev} of {repo} at {path}. If not provided, {path} defaults to the root of the repository.
- Navigating to /{repo}/-/blob/{rev}/{path} displays the blob contents for {rev} of {repo} at {path}. If not provided, {path} defaults to the root of the repository.
- Navigating to /{repo}/-/raw/{rev}/{path} displays the raw contents for {rev} of {repo} at {path}. If not provided, {path} defaults to the root of the repository.
- Navigating to /{repo}/-/commit/{commit} displays the commit message and diff for commit {commit} of repository {repo}.
- Navigating to /{repo}/-/log/{branch} displays summary information for each commit in the history of branch {branch} in repository {repo}. When navigating to /{repo}/-/log, callers are redirected to /{repo}/log/{default branch}.
- Navigating to /{repo}/-/diff/rev1..rev2 displays the diff from {rev1} to {rev2} of {repo}.
Where the variable {commit} is used above, it may refer to a commit hash or ref. If the ref is a branch, the commit is the branch's HEAD.
func (*DGit) ServeHTTP ¶
func (d *DGit) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP implements the http.Handler interface for DGit.
Directories ¶
Path | Synopsis |
---|---|
cmd
|
|
dgit
usage: dgit <command> [arguments]
|
usage: dgit <command> [arguments] |
dgit/internal/base
Package base defines the foundational structures required to build out the dgit command suite.
|
Package base defines the foundational structures required to build out the dgit command suite. |
dgit/internal/env
Package env implements the "dgit env" command
|
Package env implements the "dgit env" command |
dgit/internal/help
Package help implements the "dgit help" command
|
Package help implements the "dgit help" command |
dgit/internal/serve
Package serve implements the "dgit serve" command
|
Package serve implements the "dgit serve" command |
dgit/internal/version
Package version implements the "dgit version" command
|
Package version implements the "dgit version" command |
Package config implements DGit configuration data types
|
Package config implements DGit configuration data types |
Package data implements data types that are passed to the various templates.
|
Package data implements data types that are passed to the various templates. |
internal
|
|
convert
Package convert contains functions supporting the conversion of repository data into types used by the templates.
|
Package convert contains functions supporting the conversion of repository data into types used by the templates. |