Skip to content

shellbreaker/protoc-gen-bmicro

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

protoc-gen-bmicro

A protobuf v3 beego(v1) x go-micro(v2) code generator.

Usage

Installation

brew install protoc
git clone https://github.com/shellbreaker/protoc-gen-bmicro.git
cd protoc-gen-bmicro/cmd/protoc-genbmicro
go install

Protobuf Coding

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) {}
}

Generate Code

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

Register Gateway

func main() {
    srv := micro.NewService(micro.Name("go.rpc.test"))
    srv.Init()
    cli := srv.NewTestService("go.rpc.test", srv.Client())
    
    test.RegisterTestGateway(cli)
}

TODOs:

  • gen-code
  • beego.validation
  • rate-limiting
  • caching
  • loging
  • authorization

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages