summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/labstack/echo/v4/middleware/proxy_1_11.go
diff options
context:
space:
mode:
authorWim <wim@42.be>2019-01-31 17:06:36 +0100
committerWim <wim@42.be>2019-01-31 17:06:36 +0100
commitc81c0dd22a7779148c4890cfd4bbf490054f06f1 (patch)
tree06ce6fcdc8f3a2278a2f3050ba42088dd2e64485 /vendor/github.com/labstack/echo/v4/middleware/proxy_1_11.go
parentf8a1ab4622a5b833282e9ee42f382451d17c1a06 (diff)
downloadmatterbridge-msglm-c81c0dd22a7779148c4890cfd4bbf490054f06f1.tar.gz
matterbridge-msglm-c81c0dd22a7779148c4890cfd4bbf490054f06f1.tar.bz2
matterbridge-msglm-c81c0dd22a7779148c4890cfd4bbf490054f06f1.zip
Update vendor, move to labstack/echo/v4 Fixes #698
Diffstat (limited to 'vendor/github.com/labstack/echo/v4/middleware/proxy_1_11.go')
-rw-r--r--vendor/github.com/labstack/echo/v4/middleware/proxy_1_11.go25
1 files changed, 25 insertions, 0 deletions
diff --git a/vendor/github.com/labstack/echo/v4/middleware/proxy_1_11.go b/vendor/github.com/labstack/echo/v4/middleware/proxy_1_11.go
new file mode 100644
index 00000000..7784f9c6
--- /dev/null
+++ b/vendor/github.com/labstack/echo/v4/middleware/proxy_1_11.go
@@ -0,0 +1,25 @@
+// +build go1.11
+
+package middleware
+
+import (
+ "fmt"
+ "net/http"
+ "net/http/httputil"
+
+ "github.com/labstack/echo/v4"
+)
+
+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) {
+ desc := tgt.URL.String()
+ if tgt.Name != "" {
+ desc = fmt.Sprintf("%s(%s)", tgt.Name, tgt.URL.String())
+ }
+ c.Logger().Errorf("remote %s unreachable, could not forward: %v", desc, err)
+ c.Error(echo.NewHTTPError(http.StatusServiceUnavailable))
+ }
+ proxy.Transport = config.Transport
+ return proxy
+}