Spec-Zone.ru › Go

Пакет cgi

  • import "net/http/cgi"
  • Обзор
  • Указатель

Обзор

Пакет cgi реализует CGI (Common Gateway Interface) согласно спецификации RFC 3875.

Обратите внимание, что использование 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)

Файлы пакета

cgi_main.go child.go host.go

func Request

func Request() (*http.Request, error)

Request возвращает HTTP-запрос в соответствии с текущим окружением. Предполагается, что текущая программа запущена веб-сервером в среде CGI. Поле Body возвращённого Request заполняется, если применимо.

func RequestFromMap

func RequestFromMap(params map[string]string) (*http.Request, error)

RequestFromMap создаёт http.Request из переменных CGI. Поле Body возвращённого Request не заполняется.

func Serve

func Serve(handler http.Handler) error

Serve выполняет предоставленный Handler для текущего активного запроса CGI, если он есть. Если текущая среда CGI отсутствует, возвращается ошибка. В качестве предоставленного обработчика можно указать nil, чтобы использовать http.DefaultServeMux.

type Handler

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; added in Go 1.7

    // 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 (*Handler) ServeHTTP

func (h *Handler) ServeHTTP(rw http.ResponseWriter, req *http.Request)

© Google, Inc.
Licensed under the Creative Commons Attribution License 3.0.
http://golang.org/pkg/net/http/cgi/

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API