©
Ce document utilise Manuel du site Web PHP chinois Libérer
import "net/http/cgi"
概述
索引
cgi包实现了RFC 3875中规定的CGI(通用网关接口)。
请注意,使用CGI意味着启动一个新的进程来处理每个请求,这通常比使用长时间运行的服务器效率低。此软件包主要用于与现有系统兼容。
func Request() (*http.Request, error)
func RequestFromMap(params map[string]string) (*http.Request, error)
func Serve(handler http.Handler) error
type Handler
func (h *Handler) ServeHTTP(rw http.ResponseWriter, req *http.Request)
child.go host.go
func Request() (*http.Request, error)
请求返回当前环境中表示的HTTP请求。这假定当前程序由CGI环境中的Web服务器运行。如果适用,填充返回的请求的正文。
func RequestFromMap(params map[string]string) (*http.Request, error)
RequestFromMap从CGI变量创建一个http.Request。返回的请求的正文字段未填充。
func Serve(handler http.Handler) error
Serve在当前活动的CGI请求上执行提供的Handler,如果有的话。如果没有当前的CGI环境,则返回错误。提供的处理程序可能无法使用http.DefaultServeMux。
Handler在具有CGI环境的子进程中运行可执行文件。
type Handler struct { Path string // path to the CGI executable Root string // root URI prefix of handler or empty for "/" // Dir specifies the CGI executable's working directory. // If Dir is empty, the base directory of Path is used. // If Path has no base directory, the current working // directory is used. Dir string Env []string // extra environment variables to set, if any, as "key=value" InheritEnv []string // environment variables to inherit from host, as "key" Logger *log.Logger // optional log for errors or nil to use log.Print Args []string // optional arguments to pass to child process Stderr io.Writer // optional stderr for the child process; nil means os.Stderr // PathLocationHandler specifies the root http Handler that // should handle internal redirects when the CGI process // returns a Location header value starting with a "/", as // specified in RFC 3875 § 6.3.2. This will likely be // http.DefaultServeMux. // // If nil, a CGI response with a local URI path is instead sent // back to the client and not redirected internally. PathLocationHandler http.Handler}
func (h *Handler) ServeHTTP(rw http.ResponseWriter, req *http.Request)