protoc-gen-route

command module
v0.0.0-...-cd0c0c2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 14, 2024 License: MIT Imports: 13 Imported by: 0

README

protoc-gen-route

This is a tool to generate common route code from proto files

Installation

go install github.com/tbxark/sphere/contrib/protoc-gen-route@latest

Example

Add tbxark.options.options to the rpc method, and set the key to bot, You can also add extra options to the method.


service CounterService {
  rpc Start(StartRequest) returns (StartResponse) {
    option (tbxark.options.options) = {
      key: "bot"
    };
  }
  rpc Counter(CounterRequest) returns (CounterResponse) {
    option (tbxark.options.options) = {
      key: "bot",
      extra: [
        {
          key: "command",
          value: "count",
        },
        {
          key: "callback_query",
          value: "count",
        }
      ]
    };
  }
  rpc Unknown(UnknownRequest) returns (UnknownResponse);
}
...

And then run the command, add following to your buf.gen.yaml file

  - local: protoc-gen-route
    out: api
    opt:
      - paths=source_relative
      - options_key=bot # The key of the options
      - gen_file_suffix=_bot.pb.go # The suffix of the generated file
      - request_model=github.com/tbxark/sphere/pkg/telegram;Update
      - response_model=github.com/tbxark/sphere/pkg/telegram;Message
      - extra_data_model=github.com/tbxark/sphere/pkg/telegram;MethodExtraData
      - extra_data_constructor=github.com/tbxark/sphere/pkg/telegram;NewMethodExtraData

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL