本文整理汇总了Golang中net/http/cgi.Handler.Logger方法的典型用法代码示例。如果您正苦于以下问题:Golang Handler.Logger方法的具体用法?Golang Handler.Logger怎么用?Golang Handler.Logger使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net/http/cgi.Handler
的用法示例。
在下文中一共展示了Handler.Logger方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: 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
}