GOLANG 实现的 fastcgi

前端之家收集整理的这篇文章主要介绍了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>\n<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)
}

猜你在找的Go相关文章