// CGI example package cfg import ( "net/http" "net/http/cgi" "path" "strings" "go.stargrave.org/godlighty" "go.stargrave.org/godlighty/rc" ) func init() { host := "blog.stargrave.org" godlighty.Hosts[host] = &godlighty.HostCfg{ Root: path.Join(WWW, host), EdDSATLS: newTLSCfg(host), Hooks: []godlighty.Hook{ func(w http.ResponseWriter, r *http.Request) bool { var t string if strings.HasPrefix(r.URL.Path, "/russian") { t = "russian" } else if strings.HasPrefix(r.URL.Path, "/english") { t = "english" } else if strings.HasPrefix(r.URL.Path, "/example") { t = "example" } if t == "" { return false } r.URL.Path = strings.TrimPrefix(r.URL.Path, "/"+t) rc.RunCGIAndLog(host, w, r, &cgi.Handler{ Path: "/home/sgblog/sgblog", Dir: "/var/empty", Env: []string{"SGBLOG_CFG=/home/sgblog/" + t + ".hjson"}, }) return true }, }, } }