Esempio n. 1
0
// serve http with php script(cgi mode)
func Cgi(w http.ResponseWriter, r *http.Request, phpBin string, scriptFileName string) {
	handler := new(cgi.Handler)
	handler.Path = phpBin
	handler.Env = append(handler.Env, "REDIRECT_STATUS=CGI")
	handler.Env = append(handler.Env, "SCRIPT_FILENAME="+scriptFileName)

	handler.ServeHTTP(w, r)
}
Esempio n. 2
0
func CgiHandler(config map[string]string) http.Handler {
	h := new(cgi.Handler)

	h.Path = mustGet(config, "path")
	h.Root = mustGet(config, "mount")
	h.Dir = tryGet(config, "dir", "")
	h.Args = getSlice(config, "args")
	h.Env = getSlice(config, "env")
	h.InheritEnv = getSlice(config, "inherit")

	h.PathLocationHandler = http.DefaultServeMux

	return h
}