kataras / kataras/iris

[BUG] MVC does not support receiving protobufs

Open
#2,489 5 comments 0 reactions 1 assignee Claimed by @kataras View on GitHub
Dominant language
Go
Stars
25.6k
Forks
2.4k
PR merge metrics
No merged PRs in 30d

Description

**Describe the bug**
On the issue of receiving protobuf data exception in MVC
**To Reproduce**
1. The following is the main code segment, which works as a whole except for errors when receiving protobuf
```
app := iris.New()
return app.Run(iris.Addr(":"+port),
iris.WithKeepAlive(1*time.Minute),
iris.WithoutInterruptHandler,
iris.WithOptimizations,
iris.WithProtoJSON,
iris.WithoutBodyConsumptionOnUnmarshal,
iris.WithoutServerError(iris.ErrServerClosed),
iris.WithRemoteAddrHeader("X-Real-IP"),
)

mvcApp := mvc.New(app)

api := mvcApp.Party("/")
api.Party("test").Handle(new(controllers.TestController))
```

Question:Directly in the outermost layer directly error, the program has not been executed to the controller
Response Error:valid character '$' looking for beginning of valueinvalid character '$' looking for beginning of value

2. This code reads protobuf without problem:

```
app.Post("/read", read)

func read(ctx iris.Context) {
var request pb.FcmRequest

err := ctx.ReadProtobuf(&request)
if err != nil {
ctx.StopWithError(iris.StatusBadRequest, err)
return
}

fmt.Println(request)
}

func read(ctx iris.Context) {
var request pb.FcmRequest

err := ctx.ReadProtobuf(&request)
if err != nil {
ctx.StopWithError(iris.StatusBadRequest, err)
return
}

fmt.Println(request)

ctx.Writef("HelloRequest.Name = %s", request)
}

```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.