-
Notifications
You must be signed in to change notification settings - Fork 292
Closed
Description
The example provided in this link(https://github.com/labstack/echox/blob/master/website/content/guide/request.md) will fail with the following message:
http server started on [::]:1323
echo: http: panic serving 127.0.0.1:39328: runtime error: invalid memory address or nil pointer dereference
goroutine 18 [running]:
net/http.(*conn).serve.func1(0xc00038a000)
/home/testuser/go/src/net/http/server.go:1801 +0x147
panic(0x735ca0, 0x9b3b00)
/home/testuser/go/src/runtime/panic.go:975 +0x47a
main.(*CustomValidator).Validate(0xc0000101b8, 0x718000, 0xc00039a020, 0x0, 0x0)
/home/testuser/code/golang/validatejson/main.go:22 +0x6a
github.com/labstack/echo/v4.(*context).Validate(0xc00038a0a0, 0x718000, 0xc00039a020, 0x0, 0x0)
/home/testuser/go/pkg/mod/github.com/labstack/echo/v4@v4.2.0/context.go:433 +0x5b
main.main.func1(0x7fa880, 0xc00038a0a0, 0x0, 0x0)
/home/testuser/code/golang/validatejson/main.go:33 +0x1f1
github.com/labstack/echo/v4.(*Echo).add.func1(0x7fa880, 0xc00038a0a0, 0x0, 0x0)
/home/testuser/go/pkg/mod/github.com/labstack/echo/v4@v4.2.0/echo.go:536 +0x62
github.com/labstack/echo/v4.(*Echo).ServeHTTP(0xc0002d2800, 0x7f6920, 0xc0003a0000, 0xc000382100)
/home/testuser/go/pkg/mod/github.com/labstack/echo/v4@v4.2.0/echo.go:646 +0x187
net/http.serverHandler.ServeHTTP(0xc0002f6000, 0x7f6920, 0xc0003a0000, 0xc000382100)
/home/testuser/go/src/net/http/server.go:2843 +0xa3
net/http.(*conn).serve(0xc00038a000, 0x7f71a0, 0xc00038e000)
/home/testuser/go/src/net/http/server.go:1925 +0x8ad
created by net/http.(*Server).Serve
/home/testuser/go/src/net/http/server.go:2969 +0x36c
When using the following request
$ curl -X POST http://localhost:1323/users -H 'Content-Type: application/json' -d '{"name":"Joe","email":"joe@domain.com"}'
curl: (52) Empty reply from server
go version
go version go1.15.8 linux/amd64
$ cat go.mod
module validatejson
go 1.15
require (
github.com/go-playground/validator/v10 v10.4.1
github.com/labstack/echo/v4 v4.2.0
)
`
Metadata
Metadata
Assignees
Labels
No labels