Documentation
¶
Overview ¶
Package gofast implements the FastCGI protocol. Currently only the responder role is supported. The protocol is defined at http://www.fastcgi.com/drupal/node/22
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client interface {
// Do takes care of a proper FastCGI request
Do(req *Request) (resp *ResponsePipe, err error)
// NewRequest returns a standard FastCGI request
// with a unique request ID allocted by the client
NewRequest(*http.Request) *Request
// AllocID allocates a new reqID.
// It blocks if all possible uint16 IDs are allocated.
AllocID() uint16
// ReleaseID releases a reqID.
// It never blocks.
ReleaseID(uint16)
}
Client is a client interface of FastCGI application process through given connection (net.Conn)
type FileSystemRouter ¶
type FileSystemRouter struct {
// DocRoot stores the ordinary Apache DocumentRoot parameter
DocRoot string
// Exts stores accepted extensions
Exts []string
// DirIndex stores ordinary Apache DirectoryIndex parameter
// for to identify file to show in directory
DirIndex []string
}
FileSystemRouter handles ordinary filesystem based router like an old fashion PHP hosting environment
func (*FileSystemRouter) Router ¶
func (fs *FileSystemRouter) Router() Middleware
Router returns Middleware
type Handler ¶
type Handler interface {
SetLogger(logger *log.Logger)
ServeHTTP(w http.ResponseWriter, r *http.Request)
}
Handler is the interface for a FastCGI web server, which proxy request to FastCGI application through network port or socket
func NewHandler ¶
func NewHandler(sessionHandler SessionHandler, network, address string) Handler
NewHandler returns a new Handler interface
type Middleware ¶
type Middleware func(SessionHandler) SessionHandler
Middleware transform a SessionHandler as another SessionHandler
func Chain ¶
func Chain(middlewares ...Middleware) Middleware
Chain chains middlewares into a single middleware
type Request ¶
type Request struct {
Raw *http.Request
ID uint16
Params map[string]string
Stdin io.ReadCloser
KeepConn bool
}
Request hold information of a standard FastCGI request
type ResponsePipe ¶
type ResponsePipe struct {
// contains filtered or unexported fields
}
ResponsePipe contains readers and writers that handles all FastCGI output streams
func BasicSession ¶
func BasicSession(client Client, req *Request) (*ResponsePipe, error)
BasicSession implements SessionHandlerFunc
func NewResponsePipe ¶
func NewResponsePipe() (p *ResponsePipe)
NewResponsePipe returns an initialized new ResponsePipe struct
func (*ResponsePipe) WriteTo ¶
func (pipes *ResponsePipe) WriteTo(rw http.ResponseWriter, ew io.Writer) (err error)
WriteTo writes the given output into http.ResponseWriter
type SessionHandler ¶
type SessionHandler func(client Client, req *Request) (resp *ResponsePipe, err error)
SessionHandler handles the gofast *Reqeust with the provided given Client. The Client should properly handle the transport to the fastcgi application. Should do proper routing or other parameter mapping here.
func MapHeader ¶
func MapHeader(inner SessionHandler) SessionHandler
MapHeader implement Middleware to map header field SomeRandomField to HTTP_SOME_RANDOM_FIELD
func NewPHPFS ¶
func NewPHPFS(root string) SessionHandler
NewPHPFS returns a SessionHandler provides a classic PHP hosting environment for a HTTP session
func (SessionHandler) Handle ¶
func (handler SessionHandler) Handle(client Client, req *Request) (*ResponsePipe, error)
Handle implements SessionHandler