package main
import (
"fmt"
"io"
"net/http"
"net/http/httputil"
"net/url"
)
func ServeHTTP(w http.ResponseWriter, r *http.Request) {
if r.RequestURI == "/favicon.ico" {
io.WriteString(w, "Request path Error")
return
}
remote, err := url.Parse("http://" + "47.92.84.22")
if err != nil {
fmt.Println("json err:", err)
}
proxy := httputil.NewSingleHostReverseProxy(remote)
proxy.ServeHTTP(w, r)
}
func main() {
http.HandleFunc("/", ServeHTTP)
http.ListenAndServe(":8085", nil)
}
go 语言 http请求转发
猜你喜欢
转载自blog.csdn.net/az44yao/article/details/103537108
今日推荐
周排行