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
  • тип 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. Тело возвращаемого запроса заполняется, если применимо.

func RequestFromMap

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

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

func Serve

func Serve(handler http.Handler) error

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

тип 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