小编Wil*_*Lee的帖子

如何在使用golang http包时限制客户端IP地址

我正在使用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)

http go

3
推荐指数
1
解决办法
3728
查看次数

标签 统计

go ×1

http ×1