diff options
Diffstat (limited to 'main.go')
-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)) } |