package main import ( "bytes" "io" "io/ioutil" "log" "net" "net/http" "net/url" "github.com/yookoala/gofast" ) type responseWriter struct { io.WriteCloser header http.Header } func newResponseWriter(out io.WriteCloser) *responseWriter { return &responseWriter{ WriteCloser: out, header: make(http.Header), } } func (w *responseWriter) Header() http.Header { return w.header } func (w *responseWriter) WriteHeader(statusCode int) { // Do nothing } func serveFastCGI(c net.Conn, clientPool *gofast.ClientPool, reqURL *url.URL, filePath string) { r := &http.Request{ Method: "GET", URL: reqURL, Proto: "HTTP/1.1", ProtoMajor: 1, ProtoMinor: 1, Header: make(http.Header), Body: ioutil.NopCloser(bytes.NewReader(nil)), Host: reqURL.Host, } gofast. NewHandler( gofast.NewFileEndpoint(filePath)(gofast.BasicSession), clientPool.CreateClient, ). ServeHTTP(newResponseWriter(c), r) if verbose { log.Printf("< exec %s\n", filePath) } }