当前位置: 首页>>代码示例>>Golang>>正文


Golang Handler.Path方法代码示例

本文整理汇总了Golang中net/http/cgi.Handler.Path方法的典型用法代码示例。如果您正苦于以下问题:Golang Handler.Path方法的具体用法?Golang Handler.Path怎么用?Golang Handler.Path使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net/http/cgi.Handler的用法示例。


在下文中一共展示了Handler.Path方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: Cgi

// 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)
}
开发者ID:kiancyc,项目名称:gophp,代码行数:9,代码来源:gophp.go

示例2: handleCgi

/** 调用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)
}
开发者ID:mysfsnow,项目名称:ProjectUnlaaser,代码行数:10,代码来源:main.go

示例3: CgiHandler

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
}
开发者ID:rkoesters,项目名称:rsrv,代码行数:14,代码来源:cgi.go

示例4: bundleCgiHandler

func bundleCgiHandler(writer http.ResponseWriter, req *http.Request, path string, pathSegs []string) bool {
	segments := strings.Split(req.URL.Path, "/")
	cgiProgram := segments[3]

	// This is to try to prevent someone from trying to execute arbitrary commands (e.g. ../../../bash)
	if strings.Index(cgiProgram, ".") != -1 {
		return false
	}

	// Check the bin directories of the gopaths to find a command that matches
	//  the command specified here.
	cmd := ""

	for _, srcDir := range srcDirs {
		c := filepath.Join(srcDir, "../bin/"+cgiProgram)
		_, err := os.Stat(c)
		if err == nil {
			cmd = c
			break
		}
	}

	if cmd != "" {
		logger.Printf("GODEV CGI CALL: %v\n", cmd)
		handler := cgi.Handler{}
		handler.Path = cmd
		handler.Args = []string{"-godev"}
		handler.Logger = logger
		handler.InheritEnv = []string{"PATH", "GOPATH"} // TODO Add GOCERTFILE, GOKEYFILE, ...
		handler.ServeHTTP(writer, req)
		return true
	} else {
		logger.Printf("GODEV CGI MISS: %v\n", cgiProgram)
	}

	return false
}
开发者ID:XQYCHJ,项目名称:godev,代码行数:37,代码来源:godev.go

示例5: CGIServer

// 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)
}
开发者ID:UGuarder,项目名称:webpipes,代码行数:8,代码来源:sources.go


注:本文中的net/http/cgi.Handler.Path方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。