Пример #1
0
/** 调用CGI程序的Handler */
func handleCgi(out http.ResponseWriter, request *http.Request) {
	u := (*request).URL

	var hdl cgi.Handler
	hdl.Path = "./" + u.Path
	hdl.Root = "/cgi/"
	hdl.Dir = "."
	hdl.ServeHTTP(out, request)
}
Пример #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
}