1
0
mirror of https://github.com/labstack/echo.git synced 2025-01-12 01:22:21 +02:00

Proxy rename descr to desc

Signed-off-by: Vishal Rana <vr@labstack.com>
This commit is contained in:
Vishal Rana 2018-10-13 11:43:05 +05:30
parent bc37a3a792
commit ac1f40118a

View File

@ -4,19 +4,20 @@ package middleware
import (
"fmt"
"github.com/labstack/echo"
"net/http"
"net/http/httputil"
"github.com/labstack/echo"
)
func proxyHTTP(tgt *ProxyTarget, c echo.Context, config ProxyConfig) http.Handler {
proxy := httputil.NewSingleHostReverseProxy(tgt.URL)
proxy.ErrorHandler = func(resp http.ResponseWriter, req *http.Request, err error) {
descr := tgt.URL.String()
desc := tgt.URL.String()
if tgt.Name != "" {
descr = fmt.Sprintf("%s(%s)", tgt.Name, tgt.URL.String())
desc = fmt.Sprintf("%s(%s)", tgt.Name, tgt.URL.String())
}
c.Logger().Errorf("remote %s unreachable, could not forward: %v", descr, err)
c.Logger().Errorf("remote %s unreachable, could not forward: %v", desc, err)
c.Error(echo.ErrServiceUnavailable)
}
proxy.Transport = config.Transport