githandler

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 24, 2019 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	InfoRefsRegExp    = regexp.MustCompile(`/(.+\.git)/info/refs$`)
	UploadPackRegExp  = regexp.MustCompile(`/(.+\.git)/git-upload-pack$`)
	ReceivePackRegExp = regexp.MustCompile(`/(.+\.git)/git-receive-pack$`)

	FetchFileRegExp = regexp.MustCompile(`/(.+\.git)/raw/(.+?)/(.+)`)
)
View Source
var ErrWrongRepoPath = errors.New("wrong repository path")

Functions

func InfoRefsResponse

func InfoRefsResponse(ctx context.Context, repoPath, serviceName string) ([]byte, error)

Types

type FetchFileData

type FetchFileData struct {
	RepoPath string
	Ref      string
	Path     string
}

func ParseFetchFilePath

func ParseFetchFilePath(path string) (*FetchFileData, error)

type FetchFileHandler

type FetchFileHandler struct {
	// contains filtered or unexported fields
}

func NewFetchFileHandler

func NewFetchFileHandler(logger *zap.Logger, reposDir string, repoAbsPathFunc RepoAbsPathFunc) *FetchFileHandler

func (*FetchFileHandler) ServeHTTP

func (h *FetchFileHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type GitSmartHandler

type GitSmartHandler struct {
	// contains filtered or unexported fields
}

func NewGitSmartHandler

func NewGitSmartHandler(logger *zap.Logger, reposDir string, createRepo bool, repoAbsPathFunc RepoAbsPathFunc, repoPostCreateFunc RepoPostCreateFunc) *GitSmartHandler

func (*GitSmartHandler) ServeHTTP

func (h *GitSmartHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type RepoAbsPathFunc

type RepoAbsPathFunc func(reposDir, path string) (absPath string, exists bool, err error)

RepoAbsPathFunc is a user defined functions that, given the repo path provided in the url request, will return the file system absolute repo path and if it exists. This function should also do path validation and return ErrWrongRepoPath if path validation failed.

type RepoPostCreateFunc

type RepoPostCreateFunc func(repoPath, repoAbsPath string) error

type RequestType

type RequestType int
const (
	RequestTypeInfoRefs RequestType = iota
	RequestTypeUploadPack
	RequestTypeReceivePack
)

func MatchPath

func MatchPath(path string) (string, RequestType, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL