package main import ( "bytes" "io" "io/ioutil" "net" "net/http" "net/url" "github.com/yookoala/gofast" ) type fakeResponseWriter struct { io.WriteCloser header http.Header } func newFakeResponseWriter(out io.WriteCloser) *fakeResponseWriter { return &fakeResponseWriter{ WriteCloser: out, header: make(http.Header), } } func (w *fakeResponseWriter) Header() http.Header { return w.header } func (w *fakeResponseWriter) WriteHeader(statusCode int) { // Do nothing } func serveFastCGI(c net.Conn, connFactory gofast.ConnFactory, u *url.URL, filePath string) { header := map[string][]string{ "Accept": {"*/*"}, "Host": {u.Hostname()}, } r := &http.Request{ Method: "GET", URL: u, Proto: "HTTP/1.1", ProtoMajor: 1, ProtoMinor: 1, Header: header, Body: ioutil.NopCloser(bytes.NewReader(nil)), Host: u.Host, } gofast. NewHandler( gofast.NewFileEndpoint(filePath)(gofast.BasicSession), gofast.SimpleClientFactory(connFactory, 0), ). ServeHTTP(newFakeResponseWriter(c), r) }