nacos config
This commit is contained in:
parent
541627183b
commit
85b391a4d2
|
@ -98,22 +98,20 @@ func main() {
|
||||||
mux.Handle("/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
mux.Handle("/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
if strings.HasPrefix(r.URL.Path, "/api/") {
|
if strings.HasPrefix(r.URL.Path, "/api/") {
|
||||||
|
|
||||||
err := r.ParseMultipartForm(100 << 20)
|
r.ParseMultipartForm(100 << 20)
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
logx.Error(err)
|
// logx.Error(err)
|
||||||
}
|
// }
|
||||||
|
|
||||||
// 对/api开头的请求进行反向代理
|
// 对/api开头的请求进行反向代理
|
||||||
proxy := httputil.NewSingleHostReverseProxy(apiURL)
|
proxy := httputil.NewSingleHostReverseProxy(apiURL)
|
||||||
proxy.ErrorHandler = func(res http.ResponseWriter, req *http.Request, err error) {
|
proxy.ErrorHandler = func(res http.ResponseWriter, req *http.Request, err error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
||||||
// 在发生错误时进行处理
|
// 在发生错误时进行处理
|
||||||
logx.Error(err)
|
logx.Error(err)
|
||||||
|
logx.Error(res.Header())
|
||||||
res.WriteHeader(http.StatusNotFound) // 返回404状态码
|
res.WriteHeader(http.StatusNotFound) // 返回404状态码
|
||||||
// _, err := res.Write([]byte(err.Error()))
|
|
||||||
if err != nil {
|
|
||||||
logx.Error(err)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
proxy.ServeHTTP(w, r)
|
proxy.ServeHTTP(w, r)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user