All Projects → nulab → go-git-http-xfer

nulab / go-git-http-xfer

Licence: other
Implements Git HTTP Transport.

Programming Languages

go
31211 projects - #10 most used programming language
Dockerfile
14818 projects

Labels

Projects that are alternatives of or similar to go-git-http-xfer

Shell
Infrastructure Management Shell - Linux
Stars: ✭ 381 (+2830.77%)
Mutual labels:  httpd
Mod cluster
mod_cluster is an intelligent native Apache httpd-based and pure-Java Undertow-based load-balancer
Stars: ✭ 88 (+576.92%)
Mutual labels:  httpd
precompress
Generate pre-compressed .gz and .br files for static web servers
Stars: ✭ 27 (+107.69%)
Mutual labels:  httpd
Single File Httpd.conf
Single file httpd.conf configuration file for Apache HTTPD Server.
Stars: ✭ 7 (-46.15%)
Mutual labels:  httpd
Merecat
Small and made-easy HTTP/HTTPS server based on Jef Poskanzer's thttpd
Stars: ✭ 69 (+430.77%)
Mutual labels:  httpd
Httpd
Mirror of Apache HTTP Server. Issues: http://issues.apache.org
Stars: ✭ 2,862 (+21915.38%)
Mutual labels:  httpd
Mod md
Let's Encrypt (ACME) support for Apache httpd
Stars: ✭ 281 (+2061.54%)
Mutual labels:  httpd
mod authnz jwt
An authentication module for Apache httpd using JSON Web Tokens
Stars: ✭ 74 (+469.23%)
Mutual labels:  httpd
Mod auth gssapi
GSSAPI Negotiate module for Apache
Stars: ✭ 78 (+500%)
Mutual labels:  httpd
tiny httpd
Minimal HTTP server using good old threads + blocking IO, with a small request router.
Stars: ✭ 64 (+392.31%)
Mutual labels:  httpd
Apache24 Modules
Modules for Apache 2.4 and maybe 2.2
Stars: ✭ 12 (-7.69%)
Mutual labels:  httpd
Httpserver
A high performance, single threaded, HTTP server written in C++ as a learning tool. Uses kqueue for event management, therefore is MacOS / *BSD only!
Stars: ✭ 59 (+353.85%)
Mutual labels:  httpd
httpd-plus
Add-ons for the OpenBSD web server
Stars: ✭ 32 (+146.15%)
Mutual labels:  httpd
Caesonia
OpenBSD Email Service
Stars: ✭ 761 (+5753.85%)
Mutual labels:  httpd
logparser
Easy parsing of Apache HTTPD and NGINX access logs with Java, Hadoop, Hive, Pig, Flink, Beam, Storm, Drill, ...
Stars: ✭ 139 (+969.23%)
Mutual labels:  httpd
Apache2buddy
apache2buddy
Stars: ✭ 297 (+2184.62%)
Mutual labels:  httpd
Lear
Linux Engine for Asset Retrieval - speed-profiled C HTTP server
Stars: ✭ 165 (+1169.23%)
Mutual labels:  httpd
apachetop
apachetop
Stars: ✭ 37 (+184.62%)
Mutual labels:  httpd
apachelogs
Parse Apache access logs
Stars: ✭ 19 (+46.15%)
Mutual labels:  httpd
Docker-Httpd-Tomcat
Apache HTTPD with MOD-JK and Apache Tomcat on Docker
Stars: ✭ 30 (+130.77%)
Mutual labels:  httpd

go-git-http-xfer Build Status Coverage Status

Implements Git HTTP Transport.

Support Protocol

  • The Smart Protocol
  • The Dumb Protocol

Requires

  • Go 1.7+

Quickly Trial

Let's clone this repository and execute the following commands.

# docker build
$ docker build -t go-git-http-xfer .

# test
$ docker run --rm -v $PWD:/go/src/github.com/nulab/go-git-http-xfer go-git-http-xfer \
    bash -c "gotestcover -v -covermode=count -coverprofile=coverage.out ./..."

# run server
$ docker run -it --rm -v $PWD:/go/src/github.com/nulab/go-git-http-xfer -p 5050:5050 go-git-http-xfer \
    bash -c "go run ./example/main.go -p 5050"

# in your local machine
$ git clone http://localhost:5050/example.git

Installation

This package can be installed with the go get command:

$ go get github.com/nulab/go-git-http-xfer

Usage

Basic

package main

import (
	"log"
	"net/http"

	"github.com/nulab/go-git-http-xfer/githttpxfer"
)

func main() {
	
	ghx, err := githttpxfer.New("/data/git", "/usr/bin/git")
	if err != nil {
		log.Fatalf("GitHTTPXfer instance could not be created. %s", err.Error())
		return
	}
	
	if err := http.ListenAndServe(":5050", ghx); err != nil {
		log.Fatal("ListenAndServe: ", err)
	}
}

You can add optional parameters to constructor function.

  • DisableUploadPack : Disable git upload-pack command.
  • DisableReceivePack: Disable git receive-pack command.
  • WithoutDumbProto : Without dumb protocol handling.
  • WithoutDumbProtoExceptHead : Without dumb protocol except head handling.
	ghx, err := githttpxfer.New(
		"/data/git",
		"/usr/bin/git",
		githttpxfer.DisableUploadPack(),
		githttpxfer.DisableReceivePack(),
		githttpxfer.WithoutDumbProto(),
	)

You can add some custom route.

func main() {

	ghx, err := githttpxfer.New("/data/git", "/usr/bin/git")
	if err != nil {
		log.Fatalf("GitHTTPXfer instance could not be created. %s", err.Error())
		return
	}

	// You can add some custom route.
	ghx.Router.Add(githttpxfer.NewRoute(
		http.MethodGet,
		func (u *url.URL) *Match {
			suffix := "/hello"
			if !strings.HasSuffix(u.Path, suffix) {
				return nil
			}
			repoPath := strings.Replace(u.Path, suffix, "", 1)
			filePath := strings.Replace(u.Path, repoPath+"/", "", 1)
			return &Match{repoPath, filePath}
		},
		func(ctx githttpxfer.Context) {
			resp, req := ctx.Response(), ctx.Request()
			rp, fp := ctx.RepoPath(), ctx.FilePath()
			fmt.Fprintf(resp.Writer,
				"Hi there. URI: %s, RepoPath: %s, FilePath: %s",
				req.URL.RequestURI(), rp, fp)
		},
	))
	
	if err := http.ListenAndServe(":5050", ghx); err != nil {
		log.Fatal("ListenAndServe: ", err)
	}
}

You can add some middleware.

func main() {
	
	ghx, err := githttpxfer.New("/data/git", "/usr/bin/git")
	if err != nil {
		log.Fatalf("GitHTTPXfer instance could not be created. %s", err.Error())
		return
	}
	
	handler := Logging(ghx)
	
	if err := http.ListenAndServe(":5050", ghx); err != nil {
		log.Fatal("ListenAndServe: ", err)
	}
}

func Logging(next http.Handler) http.Handler {
	return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
		t1 := time.Now()
		next.ServeHTTP(w, r)
		t2 := time.Now()
		log.Printf("[%s] %q %v\n", r.Method, r.URL.String(), t2.Sub(t1))
	})
}

You can add some addon handler. (git archive)

import (
	"github.com/nulab/go-git-http-xfer/addon/handler/archive"
)

func main() {
	ghx, err := githttpxfer.New("/data/git", "/usr/bin/git")
	if err != nil {
		log.Fatalf("GitHTTPXfer instance could not be created. %s", err.Error())
		return
	}
	
	ghx.Router.Add(githttpxfer.NewRoute(
		archive.Method,
		archive.Pattern,
		archive.New(ghx).Archive,
	))
	
	if err := http.ListenAndServe(":5050", ghx); err != nil {
		log.Fatal("ListenAndServe: ", err)
	}
}

Reference

Bugs and Feedback

For bugs, questions and discussions please use the Github Issues.

License

MIT License

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].