aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGibheer <gibheer+git@zero-knowledge.org>2024-10-30 15:59:52 +0100
committerGibheer <gibheer+git@zero-knowledge.org>2024-10-30 15:59:52 +0100
commit339313fd01c404d8d04c7dda0e66c2fadb22a0dd (patch)
tree60d4faae8103c04467cbaf319ed64ccf477b2f3a
parent6c85311c302d2125d9206599732f334e5c00cd71 (diff)
reduce the code from cgit purpose built to cgi generic
-rw-r--r--main.go17
1 files changed, 12 insertions, 5 deletions
diff --git a/main.go b/main.go
index e3d8d91..a2decee 100644
--- a/main.go
+++ b/main.go
@@ -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))
}