package rc import ( "net/http" "net/http/cgi" "go.stargrave.org/godlighty" ) func addGitRepoCfg(host, root, gitwebCfg string) { godlighty.Hosts[host] = &godlighty.HostCfg{ TLS: newTLSCfg(host), Hooks: []godlighty.Hook{ func(w http.ResponseWriter, r *http.Request) bool { if r.URL.Path == "/" { redirect(host, w, r, "//"+host+"/", http.StatusMovedPermanently) return true } return false }, func(w http.ResponseWriter, r *http.Request) bool { runCGIAndLog(host, w, r, &cgi.Handler{ Path: "/usr/local/libexec/git-core/git-http-backend", Dir: "/var/empty", Env: []string{ "GIT_PROJECT_ROOT=" + root, "GIT_HTTP_EXPORT_ALL=", }, }) return true }, }, } host = "www." + host godlighty.Hosts[host] = &godlighty.HostCfg{ Root: "/usr/local/share/gitweb", TLS: newTLSCfg(host), Hooks: []godlighty.Hook{ func(w http.ResponseWriter, r *http.Request) bool { if r.URL.Path == "/" { runCGIAndLog(host, w, r, &cgi.Handler{ Path: "/usr/local/share/gitweb/gitweb.cgi", Env: []string{"GITWEB_CONFIG=" + gitwebCfg}, }) return true } return false }, }, } } func init() { addGitRepoCfg("git.stargrave.org", "/home/git/pub", "/home/git/stargrave.org.conf") }