fcgi

package module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 1, 2020 License: BSD-3-Clause Imports: 15 Imported by: 0

README

Go FastCGI client

Build Status GoDoc

A FastCGI client for web servers to communicate with FastCGI application servers, like those implemented in Go with net/http/fcgi, Python, and PHP. Based on Go's net/http/cgi and net/http/fcgi.

It is designed to be a drop-in replacement for net/http/cgi.

Usage

http.Handle("/trac/", &fcgi.Handler{
	Dialer: &fcgi.NetDialer{
		Network: "unix",
		Address: "/run/trac.socket",
	},
	Root: "/trac",
})

Documentation

Overview

Package fcgi implements a net/http/cgi-like FastCGI client

The protocol is not an official standard and the original documentation is no longer online. See the Internet Archive's mirror at: https://web.archive.org/web/20150420080736/http://www.fastcgi.com/drupal/node/6?q=node/22

Currently only the responder role is supported.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Dialer

type Dialer interface {
	// Dial returns a connection for use, or error if unable
	Dial(ctx context.Context) (net.Conn, error)
}

Dialer creates a connection.

type Handler

type Handler struct {
	Dialer Dialer // dialer for each request

	Path string // path to the CGI executable
	Root string // root URI prefix of handler or empty for "/"

	Env    []string    // extra environment variables to set, if any, as "key=value"
	Logger *log.Logger // optional log for errors or nil to use log.Print
	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
}

Handler delegates requests to a pre-existing process, using CGI semantics.

func (*Handler) ServeHTTP

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

type NetDialer

type NetDialer struct {
	Network string
	Address string
	// Dialer is the dialer configuration to use. nil implies default
	// configuration.
	Dialer *net.Dialer
}

NetDialer uses net.Dialer to create a connection.

func (*NetDialer) Dial

func (d *NetDialer) Dial(ctx context.Context) (net.Conn, error)

Dial creates a connection to Address in Network via Dialer.

Directories

Path Synopsis
example
app

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL