Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FallbackHandler ¶
type FallbackHandler struct {
// contains filtered or unexported fields
}
If a request represents a file that doesn't end with fallbackSuffix, serve it with http.FileHandler, otherwise serve it with fallback.
func NewFallbackHandler ¶
func NewFallbackHandler(dir string, fallbackSuffix string, fallback http.Handler) (fh *FallbackHandler)
func (*FallbackHandler) ServeHTTP ¶
func (fh *FallbackHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
type PhpHandler ¶
type PhpHandler struct {
// contains filtered or unexported fields
}
A PhpHandler represents a single PHP process running the built-in Web server.
Due to the need to check for errors in the STDERR of the process it only allows one call to ServeHTTP() at a time (using sync.Mutex).
func NewPhpHandler ¶
func NewPhpHandler(dir string, timeout time.Duration, args, ignore []string) (ph *PhpHandler, err error)
NewPhpHandler starts a new PHP server listening on the first free port (between port 8001 and 2^16).
Usage:
ph, err := NewPhpHandler("/path/to/web/root", time.Second) if err != nil { panic(err) } defer ph.Close()
timeout is in milliseconds
func (*PhpHandler) Close ¶
func (ph *PhpHandler) Close()
Close must be called after a successful call to NewPhpHandler otherwise you may get stray PHP processes floating around.
func (*PhpHandler) ServeHTTP ¶
func (ph *PhpHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP sends an http.Request to the PHP process, writes what it gets to an http.ResponseWriter.
If an error gets printed to STDERR during the request, it shows the error instead of what PHP returned. If the request takes too long it shows a message saying that the request took too long (see timeout option on NewPhpHandler).