Skip to content
New issue

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

用SQL生成的GRPC代码及proto,用proto生成网关"github.com/zhufuyi/sponge/pkg/gin/middleware" imported and not used #78

Open
hjw33210 opened this issue Oct 30, 2024 · 1 comment

Comments

@hjw33210
Copy link

hjw-admin-grpc/api/hjw_admin_grpc/v1

....\api\hjw_admin_grpc\v1\articleCats_router.pb.go:7:2: "errors" imported and not used
....\api\hjw_admin_grpc\v1\articleCats_router.pb.go:14:2: "github.com/zhufuyi/sponge/pkg/gin/middleware" imported and not used
....\api\hjw_admin_grpc\v1\articleTags_router.pb.go:7:2: "errors" imported and not used
....\api\hjw_admin_grpc\v1\articleTags_router.pb.go:14:2: "github.com/zhufuyi/sponge/pkg/gin/middleware" imported and not used
....\api\hjw_admin_grpc\v1\articles_router.pb.go:7:2: "errors" imported and not used
....\api\hjw_admin_grpc\v1\articles_router.pb.go:14:2: "github.com/zhufuyi/sponge/pkg/gin/middleware" imported and not used
....\api\hjw_admin_grpc\v1\depts_router.pb.go:7:2: "errors" imported and not used
....\api\hjw_admin_grpc\v1\depts_router.pb.go:14:2: "github.com/zhufuyi/sponge/pkg/gin/middleware" imported and not used
....\api\hjw_admin_grpc\v1\file_router.pb.go:7:2: "errors" imported and not used
....\api\hjw_admin_grpc\v1\file_router.pb.go:14:2: "github.com/zhufuyi/sponge/pkg/gin/middleware" imported and not used
....\api\hjw_admin_grpc\v1\file_router.pb.go:14:2: too many errors

sponge command ui service is running, port = 24631, verson = v1.10.3, visit http://localhost:24631 in your browser.

@zhufuyi
Copy link
Owner

zhufuyi commented Oct 31, 2024

使用proto文件生成grpc网关服务,每个proto文件下至少有一个rpc方法满足下面2个要求,不符合要求的rpc方法会被忽略生成代码,如果所有rpc方法都没有一个rpc符合要求才会产生上面错误信息。

  1. 在rpc方法设置google.api.http,示例:
  rpc Login(LoginRequest) returns (LoginReply) {
    option (google.api.http) = {
      post: "/api/v1/login"
      body: "*"
    };
  }
  1. rpc不属于stream类型。

具体可以查看生成grpc网关代码页面的protobuf文件示例
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants