We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
package main import ( "github.com/gin-gonic/gin" ) func main() { g := gin.Default() g.POST("/hello/", func(c *gin.Context) { var body TestBody err := c.ShouldBind(&body) if err != nil { c.Status(http.StatusBadRequest) } c.String(http.StatusOK, body.Msg) }) g.Run(":9000") } type TestBody struct { Msg string `json:"msg"` }
$ curl -v http://127.0.0.1:9000/get/dst/abc/ -H 'Content-Type:application/x-protobuf' -X POST -d '{"msg":"ok"}' 400 Bad Request
500 Internal Server Error and server side panic
interface conversion: *main.TestResult is not protoiface.MessageV1: missing method ProtoMessage /Users/Tevic/Work/RunTime/Go/src/runtime/iface.go:44 (0x100b124) getitab: panic(&TypeAssertionError{nil, typ, &inter.typ, name.name()}) /Users/Tevic/Work/RunTime/Go/src/runtime/iface.go:482 (0x100c164) assertE2I: return getitab(inter, t, false) /Users/Tevic/Work/RunTime/Gp/pkg/mod/github.com/gin-gonic/[email protected]/binding/protobuf.go:29 (0x14b306e) protobufBinding.BindBody: if err := proto.Unmarshal(body, obj.(proto.Message)); err != nil { /Users/Tevic/Work/RunTime/Gp/pkg/mod/github.com/gin-gonic/[email protected]/binding/protobuf.go:25 (0x14b3094) protobufBinding.Bind: return b.BindBody(buf, obj) /Users/Tevic/Work/RunTime/Gp/pkg/mod/github.com/gin-gonic/[email protected]/context.go:703 (0x14bc7d8) (*Context).ShouldBindWith: return b.Bind(c.Request, obj) /Users/Tevic/Work/RunTime/Gp/pkg/mod/github.com/gin-gonic/[email protected]/context.go:663 (0x14bc7b7) (*Context).ShouldBind: return c.ShouldBindWith(obj, b) /Users/Tevic/Dropbox/WorkSpace/Code/GoProjs/ByteDance/Snippets/Gin.go:52 (0x14cf0fb) main.func1: c.ShouldBind(&xx) /Users/Tevic/Work/RunTime/Gp/pkg/mod/github.com/gin-gonic/[email protected]/context.go:165 (0x14c5941) (*Context).Next: c.handlers[c.index](c) /Users/Tevic/Work/RunTime/Gp/pkg/mod/github.com/gin-gonic/[email protected]/recovery.go:99 (0x14c592c) CustomRecoveryWithWriter.func1: c.Next() /Users/Tevic/Work/RunTime/Gp/pkg/mod/github.com/gin-gonic/[email protected]/context.go:165 (0x14c4ba6) (*Context).Next: c.handlers[c.index](c) /Users/Tevic/Work/RunTime/Gp/pkg/mod/github.com/gin-gonic/[email protected]/logger.go:241 (0x14c4b89) LoggerWithConfig.func1: c.Next() /Users/Tevic/Work/RunTime/Gp/pkg/mod/github.com/gin-gonic/[email protected]/context.go:165 (0x14c40dd) (*Context).Next: c.handlers[c.index](c) /Users/Tevic/Work/RunTime/Gp/pkg/mod/github.com/gin-gonic/[email protected]/gin.go:489 (0x14c3d65) (*Engine).handleHTTPRequest: c.Next() /Users/Tevic/Work/RunTime/Gp/pkg/mod/github.com/gin-gonic/[email protected]/gin.go:445 (0x14c38c4) (*Engine).ServeHTTP: engine.handleHTTPRequest(c) /Users/Tevic/Work/RunTime/Go/src/net/http/server.go:2878 (0x126f7ba) serverHandler.ServeHTTP: handler.ServeHTTP(rw, req) /Users/Tevic/Work/RunTime/Go/src/net/http/server.go:1929 (0x126ae67) (*conn).serve: serverHandler{c.server}.ServeHTTP(w, w.req) /Users/Tevic/Work/RunTime/Go/src/runtime/asm_amd64.s:1581 (0x10697a0) goexit: BYTE $0x90 // NOP
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Description
How to reproduce
Expectations
Actual result
500 Internal Server Error
and server side panic
Environment
The text was updated successfully, but these errors were encountered: