?
This document uses PHP Chinese website manual Release
import "net/http/cgi"
概述
索引
cgi包實現(xiàn)了RFC 3875中規(guī)定的CGI(通用網(wǎng)關(guān)接口)。
請注意,使用CGI意味著啟動一個新的進程來處理每個請求,這通常比使用長時間運行的服務(wù)器效率低。此軟件包主要用于與現(xiàn)有系統(tǒng)兼容。
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)
請求返回當(dāng)前環(huán)境中表示的HTTP請求。這假定當(dāng)前程序由CGI環(huán)境中的Web服務(wù)器運行。如果適用,填充返回的請求的正文。
func RequestFromMap(params map[string]string) (*http.Request, error)
RequestFromMap從CGI變量創(chuàng)建一個http.Request。返回的請求的正文字段未填充。
func Serve(handler http.Handler) error
Serve在當(dāng)前活動的CGI請求上執(zhí)行提供的Handler,如果有的話。如果沒有當(dāng)前的CGI環(huán)境,則返回錯誤。提供的處理程序可能無法使用http.DefaultServeMux。
Handler在具有CGI環(huán)境的子進程中運行可執(zhí)行文件。
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)