e := echo.New()
e.Use(middleware.LoggerWithConfig(middleware.LoggerConfig{
Content-Length
header?
%q
so the single slash is escaped there. And then when echo prints the message the same thing happens and each slash is escaped again, making a single slash into four. Does anyone have an idea on how to deal with this?
\t
makes those characters appear directly in the response instead of being processed, so I'm guessing something happens there and an escaped backslash \\
in the string is returned as-is
see https://pkg.go.dev/encoding/json#Marshal
Array and slice values encode as JSON arrays, except that []byte encodes as a base64-encoded string, and a nil slice encodes as the null JSON value.
{"message":"remote unix:///tmp/ttyd.sock unreachable, could not forward: unsupported protocol scheme \"unix\""}
You could try
proxyConf := middleware.ProxyConfig{
// your other settings
Transport: &http.Transport{
DialContext: func(ctx context.Context, network, addr string) (net.Conn, error) {
return net.Dial("unix", addr)
},
},
}
e.Use(middleware.ProxyWithConfig(proxyConf))
maybe it works.
panic: echo: proxy middleware requires balancer
goroutine 1 [running]:
github.com/labstack/echo/v4/middleware.ProxyWithConfig({0x1319698, {0x0, 0x0}, 0x0, 0x0, {0x0, 0x0}, {0x13641a0, 0xc00013d040}, 0x0})
/Users/matthias/go/pkg/mod/github.com/labstack/echo/v4@v4.6.1/middleware/proxy.go:214 +0x1aa
main.main()
/Users/matthias/apigw/server.go:62 +0x194
exit status 2
`
echo: http: panic serving [::1]:61352: runtime error: invalid memory address or nil pointer dereference
goroutine 6 [running]:
net/http.(*conn).serve.func1()
/usr/local/Cellar/go/1.17.2/libexec/src/net/http/server.go:1801 +0xb9
panic({0x12b0840, 0x154adf0})
/usr/local/Cellar/go/1.17.2/libexec/src/runtime/panic.go:1047 +0x266
net/http/httputil.NewSingleHostReverseProxy(0x0)
/usr/local/Cellar/go/1.17.2/libexec/src/net/http/httputil/reverseproxy.go:144 +0x1d
github.com/labstack/echo/v4/middleware.proxyHTTP(0xc0000668a0, {0x13736f0, 0xc00018c460}, {0x1319778, {0x136a6a0, 0xc0000134e0}, 0x0, 0x0, {0x0, 0x0}, ...})
/Users/matthias/go/pkg/mod/github.com/labstack/echo/v4@v4.6.1/middleware/proxy.go:279 +0x45
github.com/labstack/echo/v4/middleware.ProxyWithConfig.func1.1({0x13736f0, 0xc00018c460})
/Users/matthias/go/pkg/mod/github.com/labstack/echo/v4@v4.6.1/middleware/proxy.go:260 +0x5d0
github.com/labstack/echo/v4.(*Echo).add.func1({0x13736f0, 0xc00018c460})
/Users/matthias/go/pkg/mod/github.com/labstack/echo/v4@v4.6.1/echo.go:552 +0x51
github.com/labstack/echo/v4.(*Echo).ServeHTTP(0xc000014fc0, {0x136a8e0, 0xc00017e2a0}, 0xc00019e000)
/Users/matthias/go/pkg/mod/github.com/labstack/echo/v4@v4.6.1/echo.go:662 +0x3bc
net/http.serverHandler.ServeHTTP({0xc0001917d0}, {0x136a8e0, 0xc00017e2a0}, 0xc00019e000)
/usr/local/Cellar/go/1.17.2/libexec/src/net/http/server.go:2878 +0x43b
net/http.(*conn).serve(0xc00018c3c0, {0x136bb00, 0xc0001916e0})
/usr/local/Cellar/go/1.17.2/libexec/src/net/http/server.go:1929 +0xb08
created by net/http.(*Server).Serve
/usr/local/Cellar/go/1.17.2/libexec/src/net/http/server.go:3033 +0x4e8
when proxying multiple things like:
serverA -> /
serverB -> /api
can I make serverA not overwrite serverB on /api? Because I can't figure it out haha