A protobuf v3 beego(v1) x go-micro(v2) code generator.
brew install protoc
git clone https://github.com/shellbreaker/protoc-gen-bmicro.git
cd protoc-gen-bmicro/cmd/protoc-genbmicro
go install
Use leading comment at service.rpc.[method]: // @router /api/v1/file [get]
syntax = "proto3";
package test;
option go_package = ".;test";
import "gogo.proto";
message Request {
string query = 1 [(gogoproto.moretags) = "form:\"query\""]; //use form tag to get query/form value
}
message Response {
int64 code = 2;
string msg = 4;
}
service Test {
// @router /api/v1/resource [get]
rpc Get(Request) returns (Response) {}
// @router /api/v1/resource [post]
rpc Post(Request) returns (Response) {}
}
protoc -I="." -I="$GOPATH/src/github.com/gogo/protobuf/gogoproto" --gofast_out=/path/to/your/dir \
--micro_out=/path/to/your/dir --bmicro_out=/path/to/your/dir /your/protobuf.proto
func main() {
srv := micro.NewService(micro.Name("go.rpc.test"))
srv.Init()
cli := srv.NewTestService("go.rpc.test", srv.Client())
test.RegisterTestGateway(cli)
}
- gen-code
- beego.validation
- rate-limiting
- caching
- loging
- authorization