我正在写一些webservices返回JSON数据,这些数据有很多用户.
与仅使用go http服务器相比,在我的服务器前使用Nginx有什么好处?
我正在使用golang http包.服务器如何限制客户端IP地址?
func (s *Worker) Run(c chan error) {
apiMux := http.NewServeMux()
apiMux.HandleFunc("/test", s.test)
apiMux.HandleFunc("/block/create", s.CreateBlock)
apiMux.HandleFunc("/block/delete", s.DeleteBlock)
apiServer := &http.Server{
Addr: "0.0.0.0:" + strconv.Itoa(s.ListenPort),
Handler: apiMux,
}
go func() {
log.Println("Worker listening on " + apiServer.Addr)
c <- apiServer.ListenAndServe()
}()
}
Run Code Online (Sandbox Code Playgroud)