Documentation ¶
Index ¶
- Constants
- func NewServer(gs GitServer, opts ...ServerOption) http.Handler
- type DebugLogger
- type GitServer
- type GoGitServer
- func (s *GoGitServer) NewInfoRefs(repoName string) InfoRefser
- func (s *GoGitServer) NewReceivePack(repoName string) ReceivePacker
- func (s *GoGitServer) NewUploadPack(repoName string) UploadPacker
- func (s *GoGitServer) WithLogger(logger ...interface{})
- func (s *GoGitServer) WithPostReceiveHook(fn cfg.PostReceivePackHookFunc)
- func (s *GoGitServer) WithPreReceiveHook(fn cfg.PreReceivePackHookFunc)
- type InfoLogger
- type InfoRefs
- type InfoRefser
- type ReceivePack
- type ReceivePacker
- type Server
- type ServerOption
- func WithLogger(logger ...interface{}) ServerOption
- func WithMiddleware(wares ...func(http.Handler) http.Handler) ServerOption
- func WithPathPrefix(prefix string) ServerOption
- func WithPostReceiveHook(fn func(io.Writer, *cfg.PostReceivePackHookData)) ServerOption
- func WithPreReceiveHook(...) ServerOption
- type UploadPack
- type UploadPacker
Constants ¶
const ( ErrSession strErr = "%s session: %v" ErrSessionAdvRefs strErr = "%s session advertised references: %v" ErrPackDecode strErr = "pack decode: %v" ErrPackScanAdvRefs strErr = "pack scan [1] advertised references: %v" ErrReceivePack strErr = "bad receive pack: %v" ErrUploadPackRequest strErr = "bad upload pack: %v" ErrUploadPack strErr = "bad upload pack: %v" ErrTransportEndpoint strErr = "repo [%s] endpoint invalid: %v" ErrNoServiceFound strErr = "no service found" ErrEmptyHookData strErr = "empty receive-pack hook data" )
all provided errors
Variables ¶
This section is empty.
Functions ¶
Types ¶
type DebugLogger ¶
DebugLogger wrap *log.Loggers with this to display debug logging
type GitServer ¶
type GitServer interface { NewInfoRefs(repoName string) InfoRefser NewReceivePack(repoName string) ReceivePacker NewUploadPack(repoName string) UploadPacker WithLogger(...interface{}) WithPreReceiveHook(cfg.PreReceivePackHookFunc) WithPostReceiveHook(cfg.PostReceivePackHookFunc) }
GitServer is the interface used to interact with the git server via HTTP
type GoGitServer ¶
type GoGitServer struct {
// contains filtered or unexported fields
}
GoGitServer wraps concepts for go-git into a GitServer HTTP interface
func LoadGoGit ¶
func LoadGoGit(m map[string]*git.Repository, endpoint string) *GoGitServer
LoadGoGit loads a mapping of git repositories (go-git) to a repository endpoint
func (*GoGitServer) NewInfoRefs ¶
func (s *GoGitServer) NewInfoRefs(repoName string) InfoRefser
NewInfoRefs returns a new InfoRefs object to handle InfoRefs requests
func (*GoGitServer) NewReceivePack ¶
func (s *GoGitServer) NewReceivePack(repoName string) ReceivePacker
NewReceivePack returns a new ReceivePack object
func (*GoGitServer) NewUploadPack ¶
func (s *GoGitServer) NewUploadPack(repoName string) UploadPacker
NewUploadPack returns a new UploadPack object
func (*GoGitServer) WithLogger ¶
func (s *GoGitServer) WithLogger(logger ...interface{})
WithLogger takes in logger/s to display debug and info logs for the GoGitServer object
func (*GoGitServer) WithPostReceiveHook ¶
func (s *GoGitServer) WithPostReceiveHook(fn cfg.PostReceivePackHookFunc)
WithPostReceiveHook sets the post-receive hook for receive-pack requests
func (*GoGitServer) WithPreReceiveHook ¶
func (s *GoGitServer) WithPreReceiveHook(fn cfg.PreReceivePackHookFunc)
WithPreReceiveHook sets the pre-receive hook for receive-pack requests
type InfoLogger ¶
InfoLogger wrap *log.Loggers with this to display info logging
type InfoRefs ¶
type InfoRefs struct { *GoGitServer // contains filtered or unexported fields }
InfoRefs holds all of the data needed to handle the git interface for info-ref requests
func (*InfoRefs) DoHTTP ¶
func (ir *InfoRefs) DoHTTP(w http.ResponseWriter, r *http.Request) InfoRefser
DoHTTP takes in a HTTP request and decodes what is supposed to happen if there are any errors then this method is skipped, and errors can be checked with the Err() method
type InfoRefser ¶
type InfoRefser interface { DoHTTP(http.ResponseWriter, *http.Request) InfoRefser Err() error }
InfoRefser returns HTTP requests for '/info/ref'
type ReceivePack ¶
type ReceivePack struct { *GoGitServer // contains filtered or unexported fields }
ReceivePack holds all of the data needed to handle the git interface for receive-pack requests through HTTP
func (*ReceivePack) Cleanup ¶
func (rp *ReceivePack) Cleanup()
Cleanup takes any functions that were collected and runs them. This is for deferred processes
func (*ReceivePack) DoHTTP ¶
func (rp *ReceivePack) DoHTTP(w http.ResponseWriter, r *http.Request) ReceivePacker
DoHTTP takes in a HTTP request and decodes what is supposed to happen if there are any errors then this method is skipped, and errors can be checked with the Err() method
func (*ReceivePack) Err ¶
func (rp *ReceivePack) Err() error
Err returns the error that was collected during the receive-pack processing
type ReceivePacker ¶
type ReceivePacker interface { DoHTTP(http.ResponseWriter, *http.Request) ReceivePacker Cleanup() Err() error }
ReceivePacker returns HTTP requests for '/receive-pack'
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server holds the handlers, middleware and mux for requests that the git client can make via HTTP
func (*Server) InfoRefsHandler ¶
func (s *Server) InfoRefsHandler(w http.ResponseWriter, r *http.Request)
InfoRefsHandler handles HTTP requests for 'info-refs/'
func (*Server) ReceivePackHandler ¶
func (s *Server) ReceivePackHandler(w http.ResponseWriter, r *http.Request)
ReceivePackHandler handles HTTP requests for 'receive-pack/'
func (*Server) ServeHTTP ¶
func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP serves the internal muxer for the http handler
func (*Server) UploadPackHandler ¶
func (s *Server) UploadPackHandler(w http.ResponseWriter, r *http.Request)
UploadPackHandler handles HTTP requests for 'upload-pack/'
type ServerOption ¶
type ServerOption func(*Server)
ServerOption provides functional options for Server objects in cfghttp
func WithLogger ¶
func WithLogger(logger ...interface{}) ServerOption
WithLogger adds a logger to the library. If *log.Logger is used then both debug and info logs will be displayed. Wrap a *log.Logger in DebugLogger or InfoLogger to display just the logs for one level.
func WithMiddleware ¶
func WithMiddleware(wares ...func(http.Handler) http.Handler) ServerOption
WithMiddleware adds any middleware to the HTTP server (i.e. can be used for auth)
func WithPathPrefix ¶
func WithPathPrefix(prefix string) ServerOption
WithPathPrefix adds a http path prefix before any of the http path patterns
func WithPostReceiveHook ¶
func WithPostReceiveHook(fn func(io.Writer, *cfg.PostReceivePackHookData)) ServerOption
WithPostReceiveHook adds a post-receive hook to the handler. Return a nil error to indicate post-receive hook success. Return a non-nil error to reject the post-receive hook. (Note the limitation of pre-receive hooks at: https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks#_code_post_receive_code)
func WithPreReceiveHook ¶
func WithPreReceiveHook(fn func(io.Writer, *cfg.PreReceivePackHookData) (string, *cfg.ReceivePackHookError)) ServerOption
WithPreReceiveHook adds a pre-receive hook to the handler. Return a nil error to indicate pre-receive hook success. Return a non-nil error to reject the pre-receive hook. (Note the limitation of pre-receive hooks at: https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks#_code_pre_receive_code)
type UploadPack ¶
type UploadPack struct { *GoGitServer // contains filtered or unexported fields }
UploadPack holds all of the data needed to handle the git interface for upload-pack requests for HTTP
func (*UploadPack) Cleanup ¶
func (up *UploadPack) Cleanup()
Cleanup takes any functions that were collected and runs them. This is for deferred processes
func (*UploadPack) DoHTTP ¶
func (up *UploadPack) DoHTTP(w http.ResponseWriter, r *http.Request) UploadPacker
DoHTTP takes in a HTTP request and decodes what is supposed to happen if there are any errors then this method is skipped, and errors can be checked with the Err() method
func (*UploadPack) Err ¶
func (up *UploadPack) Err() error
Err returns the error that was collected during the upload-pack processing
type UploadPacker ¶
type UploadPacker interface { DoHTTP(http.ResponseWriter, *http.Request) UploadPacker Cleanup() Err() error }
UploadPacker returns HTTP requests for '/upload-pack'