lura
lura copied to clipboard
Removal of engine (gin) default settings (e.g. RedirectFixedPath)
Describe the bug In case of the usage of the gin engine, the setting RedirectFixedPath breaks any middleware including NoRoute (default 404) handlers and panics (see router/gin/router.go ).
To Reproduce Steps to reproduce the behavior:
- Usage of gin engine (gin.Default()) in any NewFactory (e.g. https://github.com/devopsfaith/krakend-examples/tree/master/gin/)
- Request for non lura URI e.g. /not-there
Expected behavior Execution of NoRoute handler (in case of gin.Default()) and any configured middleware
Logs 2021/07/11 11:16:12 http: panic serving 127.0.0.1:48994: invalid node type goroutine 133 [running]: net/http.(*conn).serve.func1(0xc0000c4dc0) /opt/go1.16.linux-amd64/src/net/http/server.go:1824 +0x153 panic(0xf85140, 0x11ba830) /opt/go1.16.linux-amd64/src/runtime/panic.go:971 +0x499 github.com/gin-gonic/gin.(*node).findCaseInsensitivePathRec(0xc0002ef340, 0xc0006921e4, 0xc, 0xc000530080, 0x0, 0x80, 0x100000000, 0xc0000ae201, 0xc0000298c0, 0x0) /home/lhgdam4/go/pkg/mod/github.com/gin-gonic/[email protected]/tree.go:790 +0x109b github.com/gin-gonic/gin.(*node).findCaseInsensitivePath(0xc0002ef340, 0xc0006921e4, 0xc, 0x1, 0xc, 0x203000, 0x9, 0x1) /home/lhgdam4/go/pkg/mod/github.com/gin-gonic/[email protected]/tree.go:597 +0xb6 github.com/gin-gonic/gin.redirectFixedPath(0xc000344400, 0xc0002ef340, 0x1, 0xc00050e1b0) /home/lhgdam4/go/pkg/mod/github.com/gin-gonic/[email protected]/gin.go:557 +0x77 github.com/gin-gonic/gin.(*Engine).handleHTTPRequest(0xc00010e680, 0xc000344400) /home/lhgdam4/go/pkg/mod/github.com/gin-gonic/[email protected]/gin.go:498 +0x60d github.com/gin-gonic/gin.(*Engine).ServeHTTP(0xc00010e680, 0x11dc1f0, 0xc0005a4540, 0xc000344300) /home/lhgdam4/go/pkg/mod/github.com/gin-gonic/[email protected]/gin.go:445 +0x15c net/http.serverHandler.ServeHTTP(0xc0003ac2a0, 0x11dc1f0, 0xc0005a4540, 0xc000344300) /opt/go1.16.linux-amd64/src/net/http/server.go:2887 +0xa3 net/http.(*conn).serve(0xc0000c4dc0, 0x11ddb80, 0xc00004a480) /opt/go1.16.linux-amd64/src/net/http/server.go:1952 +0x8cd created by net/http.(*Server).Serve /opt/go1.16.linux-amd64/src/net/http/server.go:3013 +0x39b
Additional context If someone still depend on this setting, it would be wise to set it right after gin.Default() and before the NewFactory gets called.