diff options
| author | Gibheer <gibheer+git@zero-knowledge.org> | 2024-10-30 15:59:52 +0100 | 
|---|---|---|
| committer | Gibheer <gibheer+git@zero-knowledge.org> | 2024-10-30 15:59:52 +0100 | 
| commit | 339313fd01c404d8d04c7dda0e66c2fadb22a0dd (patch) | |
| tree | 60d4faae8103c04467cbaf319ed64ccf477b2f3a | |
| parent | 6c85311c302d2125d9206599732f334e5c00cd71 (diff) | |
reduce the code from cgit purpose built to cgi generic
| -rw-r--r-- | main.go | 17 | 
1 files changed, 12 insertions, 5 deletions
@@ -1,19 +1,26 @@  package main  import ( +	"flag"  	"log"  	"net/http"  	"net/http/cgi" +	"strings"  )  func main() { +	path := flag.String("path", "", "Path to the cgi binary") +	dir := flag.String("dir", "", "set a different working directory from the base path of 'path'") +	env := flag.String("env", "", "set environment variables for the CGI process") +	prefix := flag.String("uri-prefix", "/", "set the URL prefix when the CGI process is hosted in a sub directory") +	flag.Parse() +  	forwarder := &cgi.Handler{ -		Path: "/usr/lib/cgit/cgit.cgi", -		Root: "/", -		Env:  []string{"CGIT_CONFIG=cgitrc"}, -		Dir:  "/home/gibheer/projects/", +		Path: *path, +		Root: *prefix, +		Env:  strings.Split(*env, ","), +		Dir:  *dir,  	} -	http.Handle("/assets/", http.StripPrefix("/assets", http.FileServer(http.Dir("/usr/share/webapps/cgit/"))))  	http.Handle("/", forwarder)  	log.Fatalf("server stopped working: %s", http.ListenAndServe(":8080", nil))  }  | 
