GOLANG 实现的 fastcgi
server { listen 80; server_name go.dev; root /root/go/src/godev; index index.html; #gzip off; #proxy_buffering off;
location / { try_files $uri $uri/; }
location ~ /app.* { include fastcgi.conf; fastcgi_pass 127.0.0.1:9001; }
try_files $uri $uri.html =404; }
package main
import ( "net" "net/http" "net/http/fcgi" )
type FastCGIServer struct{}
func (s FastCGIServer) ServeHTTP(resp http.ResponseWriter, req *http.Request) { resp.Write([]byte("<h1>Hello, 世界</h1> <p>Behold my Go web app.</p>")) }
func main() { listener, _ := net.Listen("tcp", "127.0.0.1:9001") srv := new(FastCGIServer) fcgi.Serve(listener, srv) } 阅读更多
声明:该文观点仅代表作者本人,牛骨文系教育信息发布平台,牛骨文仅提供信息存储空间服务。