You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
服务端错误:
2024-09-10 00:09:06.615 DEBUG server/service.go:235 service: helloworld.HelloWorldService handle err (if caused by health checking, this error can be ignored): type:framework, code:1, msg:service codec Unmarshal: proto: (line 2:5): unknown field "xxx"
What is the solution you'd like?
What alternatives have you considered?
Could you provide additional context?
The text was updated successfully, but these errors were encountered:
The default serialization type for application/json is codec.SerializationTypeJSON. Its implementation is jsonpb. When the request struct to be unmarshaled on comes from protobuf pb stub code, it will use jsonpb serializer, which ignores the json:"xxx" tag.
Possible fix: re-register codec.SerializationTypeJSON with std/json or jsoniter (used by the framework), such as:
Is your feature request related to a problem?
syntax = "proto3";
package helloworld;
import "trpc/proto/trpc_options.proto";
import "trpc/swagger/swagger.proto";
import "validate/validate.proto";
option go_package = "trpc-http-demo/helloworld";
// HelloRequest is hello request.
message HelloRequest {
string msg = 1 [ (trpc.go_tag)='json:"xxx"', (validate.rules).string.email=true];
}
// HelloResponse is hello response.
message HelloResponse {
string msg = 1;
}
// HelloWorldService handles hello request and echo message.
service HelloWorldService {
// Hello says hello.
//@alias="/api/helloworld"
rpc Hello(HelloRequest) returns(HelloResponse);
}
运行命令行阐述 项目:
trpc create --protocol http -p ./hello-world.proto -f -o . --alias --gotag --validate
修改配置文件,http端口号为9100
使用http client 调用:
![image](https://private-user-images.githubusercontent.com/6417640/365726391-69cd2514-f75d-4873-a5e4-5cfca7310527.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk1MDIyNTgsIm5iZiI6MTczOTUwMTk1OCwicGF0aCI6Ii82NDE3NjQwLzM2NTcyNjM5MS02OWNkMjUxNC1mNzVkLTQ4NzMtYTVlNC01Y2ZjYTczMTA1MjcucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI1MDIxNCUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNTAyMTRUMDI1OTE4WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9MTlmZjY4OTliZDNhMGY0MmNjNTgyZWQ1ZWY4ZTFjMjE0M2RhYTM5MTk1OTg0MTc3Yzg1M2ViNWQ4NGEwODFmZiZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.rZ6-K69qi9fnVegFYJWTHvZfeK_sqYM7ncKKp-63wao)
5
服务端错误:
2024-09-10 00:09:06.615 DEBUG server/service.go:235 service: helloworld.HelloWorldService handle err (if caused by health checking, this error can be ignored): type:framework, code:1, msg:service codec Unmarshal: proto: (line 2:5): unknown field "xxx"
What is the solution you'd like?
What alternatives have you considered?
Could you provide additional context?
The text was updated successfully, but these errors were encountered: