Ejemplo n.º 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)
}
Ejemplo 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
}
Ejemplo n.º 3
0
// Serve a CGI application 'path', stripping 'prefix' from the URL being
// requested
func CGIServer(path, prefix string) Component {
	handler := new(cgi.Handler)
	handler.Path = path
	handler.Root = prefix
	return NewHandlerComponent(handler)
}