Documentation ¶
Overview ¶
Package fastcgi has middleware that acts as a FastCGI client. Requests that get forwarded to FastCGI stop the middleware execution chain. The most common use for this package is to serve PHP websites via php-fpm.
Index ¶
- Constants
- type FCGIClient
- func (this *FCGIClient) Close()
- func (this *FCGIClient) Delete(p map[string]string, bodyType string, body io.Reader, l int) (resp *http.Response, err error)
- func (this *FCGIClient) Do(p map[string]string, req io.Reader) (r io.Reader, err error)
- func (this *FCGIClient) Get(p map[string]string) (resp *http.Response, err error)
- func (this *FCGIClient) Head(p map[string]string) (resp *http.Response, err error)
- func (this *FCGIClient) Options(p map[string]string) (resp *http.Response, err error)
- func (this *FCGIClient) Patch(p map[string]string, bodyType string, body io.Reader, l int) (resp *http.Response, err error)
- func (this *FCGIClient) Post(p map[string]string, bodyType string, body io.Reader, l int) (resp *http.Response, err error)
- func (this *FCGIClient) PostFile(p map[string]string, data url.Values, file map[string]string) (resp *http.Response, err error)
- func (this *FCGIClient) PostForm(p map[string]string, data url.Values) (resp *http.Response, err error)
- func (this *FCGIClient) Put(p map[string]string, bodyType string, body io.Reader, l int) (resp *http.Response, err error)
- func (this *FCGIClient) Request(p map[string]string, req io.Reader) (resp *http.Response, err error)
- type Handler
- type Rule
Constants ¶
const ( FCGI_BEGIN_REQUEST uint8 = iota + 1 FCGI_ABORT_REQUEST FCGI_END_REQUEST FCGI_PARAMS FCGI_STDIN FCGI_STDOUT FCGI_STDERR FCGI_DATA FCGI_GET_VALUES FCGI_GET_VALUES_RESULT FCGI_UNKNOWN_TYPE FCGI_MAXTYPE = FCGI_UNKNOWN_TYPE )
const ( FCGI_RESPONDER uint8 = iota + 1 FCGI_AUTHORIZER FCGI_FILTER )
const ( FCGI_REQUEST_COMPLETE uint8 = iota FCGI_CANT_MPX_CONN FCGI_OVERLOADED FCGI_UNKNOWN_ROLE )
const ( FCGI_MAX_CONNS string = "MAX_CONNS" FCGI_MAX_REQS string = "MAX_REQS" FCGI_MPXS_CONNS string = "MPXS_CONNS" )
const FCGI_HEADER_LEN uint8 = 8
const FCGI_KEEP_CONN uint8 = 1
const FCGI_LISTENSOCK_FILENO uint8 = 0
const FCGI_NULL_REQUEST_ID uint8 = 0
const VERSION_1 uint8 = 1
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FCGIClient ¶
type FCGIClient struct {
// contains filtered or unexported fields
}
func Dial ¶
func Dial(network, address string) (fcgi *FCGIClient, err error)
Connects to the fcgi responder at the specified network address. See func net.Dial for a description of the network and address parameters.
func (*FCGIClient) Delete ¶ added in v0.6.0
func (this *FCGIClient) Delete(p map[string]string, bodyType string, body io.Reader, l int) (resp *http.Response, err error)
Delete issues a DELETE request to the fcgi responder.
func (*FCGIClient) Do ¶
Do made the request and returns a io.Reader that translates the data read from fcgi responder out of fcgi packet before returning it.
func (*FCGIClient) Options ¶ added in v0.6.0
Options issues an OPTIONS request to the fcgi responder.
func (*FCGIClient) Patch ¶ added in v0.6.0
func (this *FCGIClient) Patch(p map[string]string, bodyType string, body io.Reader, l int) (resp *http.Response, err error)
Patch issues a PATCH request to the fcgi responder.
func (*FCGIClient) Post ¶
func (this *FCGIClient) Post(p map[string]string, bodyType string, body io.Reader, l int) (resp *http.Response, err error)
Post issues a POST request to the fcgi responder. with request body in the format that bodyType specified
func (*FCGIClient) PostFile ¶
func (this *FCGIClient) PostFile(p map[string]string, data url.Values, file map[string]string) (resp *http.Response, err error)
PostFile issues a POST to the fcgi responder in multipart(RFC 2046) standard, with form as a string key to a list values (url.Values), and/or with file as a string key to a list file path.
func (*FCGIClient) PostForm ¶
func (this *FCGIClient) PostForm(p map[string]string, data url.Values) (resp *http.Response, err error)
PostForm issues a POST to the fcgi responder, with form as a string key to a list values (url.Values)
type Handler ¶
type Handler struct { Next middleware.Handler Rules []Rule Root string AbsRoot string // same as root, but absolute path FileSys http.FileSystem // These are sent to CGI scripts in env variables SoftwareName string SoftwareVersion string ServerName string ServerPort string }
Handler is a middleware type that can handle requests as a FastCGI client.
type Rule ¶
type Rule struct { // The base path to match. Required. Path string // The address of the FastCGI server. Required. Address string // Always process files with this extension with fastcgi. Ext string // The path in the URL will be split into two, with the first piece ending // with the value of SplitPath. The first piece will be assumed as the // actual resource (CGI script) name, and the second piece will be set to // PATH_INFO for the CGI script to use. SplitPath string // If the URL ends with '/' (which indicates a directory), these index // files will be tried instead. IndexFiles []string // Environment Variables EnvVars [][2]string }
Rule represents a FastCGI handling rule.