Skip to content

Commit 913441e

Browse files
author
Asim Aslam
committed
update for 2018
1 parent 276e538 commit 913441e

File tree

2 files changed

+56
-37
lines changed

2 files changed

+56
-37
lines changed

README.md

Lines changed: 43 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,50 @@
1-
Git-Http-Backend.Go - Git Smart-HTTP Server Handler
2-
======================================================
1+
# Git HTTP Backend
32

43
This is a Go based implementation of Grack (a Rack application), which aimed
54
to replace the builtin git-http-backed CGI handler distributed with C Git.
65
Grack was written to allow far more webservers to handle Git smart http
76
requests. The aim of this project is to improve Git smart http performance by
87
utilising the power of Go.
98

10-
Dependencies
11-
========================
12-
* Go - http://golang.org
13-
* Git >= 1.7
14-
15-
Quick Start
16-
========================
17-
$ (edit git-http-backend.go to set GitBinPath and ProjectRoot)
18-
$ go run git-http-backend.go
19-
$ git clone http://127.0.0.1:8080/asim/git-http-backend.git
20-
21-
License
22-
========================
23-
(The MIT License)
24-
25-
Copyright (c) 2013 Asim Aslam <[email protected]>
26-
27-
Permission is hereby granted, free of charge, to any person obtaining
28-
a copy of this software and associated documentation files (the
29-
'Software'), to deal in the Software without restriction, including
30-
without limitation the rights to use, copy, modify, merge, publish,
31-
distribute, sublicense, and/or sell copies of the Software, and to
32-
permit persons to whom the Software is furnished to do so, subject to
33-
the following conditions:
34-
35-
The above copyright notice and this permission notice shall be
36-
included in all copies or substantial portions of the Software.
37-
38-
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
39-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
40-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
41-
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
42-
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
43-
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
44-
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
9+
## Dependencies
10+
11+
- Git >= 1.7
12+
13+
## Install
14+
15+
```
16+
go get github.com/asim/git-http-backend
17+
```
18+
19+
## Usage
20+
21+
```
22+
git-http-backend --project_root=/tmp --git_bin_path=/usr/bin/git
23+
```
24+
25+
## License
26+
27+
```
28+
(The MIT License)
29+
30+
Copyright (c) 2013 Asim Aslam <[email protected]>
31+
32+
Permission is hereby granted, free of charge, to any person obtaining
33+
a copy of this software and associated documentation files (the
34+
'Software'), to deal in the Software without restriction, including
35+
without limitation the rights to use, copy, modify, merge, publish,
36+
distribute, sublicense, and/or sell copies of the Software, and to
37+
permit persons to whom the Software is furnished to do so, subject to
38+
the following conditions:
39+
40+
The above copyright notice and this permission notice shall be
41+
included in all copies or substantial portions of the Software.
42+
43+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
44+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
45+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
46+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
47+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
48+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
49+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
50+
```

git-http-backend.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package main
22

33
import (
44
"compress/gzip"
5+
"flag"
56
"fmt"
67
"io"
78
"log"
@@ -57,6 +58,16 @@ var services = map[string]Service{
5758
"(.*?)/objects/pack/pack-[0-9a-f]{40}\\.idx$": Service{"GET", getIdxFile, ""},
5859
}
5960

61+
var (
62+
address = ":8080"
63+
)
64+
65+
func init() {
66+
flag.StringVar(&config.ProjectRoot, "project_root", config.ProjectRoot, "set project root")
67+
flag.StringVar(&config.GitBinPath, "git_bin_path", config.GitBinPath, "set git bin path")
68+
flag.StringVar(&address, "server_address", address, "set server address")
69+
}
70+
6071
// Request handling function
6172

6273
func requestHandler() http.HandlerFunc {
@@ -348,6 +359,8 @@ func hdrCacheForever(w http.ResponseWriter) {
348359
// Main
349360

350361
func main() {
362+
flag.Parse()
363+
351364
http.HandleFunc("/", requestHandler())
352365

353366
err := http.ListenAndServe(":8080", nil)

0 commit comments

Comments
 (0)