Giter Club home page Giter Club logo

protoc-gen-bic's Introduction

protoc-gen-bic

protoc-gen-bic是一款强大、易用、优雅的接口生成工具。它设计用于解决基于protobuf的http接口定义,自动生成客户端(ts,js)和服务端(go)接口代码和接口文档。

服务端基于gin web框架构建模板,通过读取Protobuf的message和service构建服务注册和调用。

安装与验证

  1. 安装
go install github.com/ShuaiGao/protoc-gen-bic@latest

或在release中下载发布的 protoc-gen-bic 包

另外 protoc 文件下载地址 https://github.com/protocolbuffers/protobuf/releases/tag/v3.13.0

  1. 验证
$ ./protoc-gen-bic --version
protoc-gen-bic 2.0.5

构建一个服务

服务构建,参见 example 目录下的 simple-go 项目,其中client目录仅仅用于存储客户端生成代码

或一个参照完整示例项目

为避免重复造轮子,该示例中引入了一些其他工具,快捷方便地构建系统代码。

支持语言

支持生成下面语言的接口代码

  • go
  • ts
  • js

特性

service 支持标签 @root,可用于设置url的前缀

在service定义中,rpc 方法通过注释指定api接口特性,特性支持下面标签(不区分大小写)

序号 标签名 标签含义
1 Summary 接口注释
2 Doc 同 summary 标签
2 Url 支持url参数,支持数据类型 int,uint,string,int64,uint64
3 Method http方法,支持:get、post、patch、delete,可缺省使用,会自动识别pb定义的rpc方法名前缀
4 Client-xxx 用于生成客户端request填充自定义参数xxx
5 void 服务端生成接口不返回数据,交由接口自行处理
6 bind 服务端数据绑定,默认根据 method 区分使用 ShouldBindJSON、ShouldBindQuery 方法,当添加 bind 标签时,使用 ShouldBind 方法

联系

欢迎交流技术方法,邮箱:[email protected]

license

protoc-gen-bic is licensed under the MIT license

protoc-gen-bic's People

Contributors

shuaigao avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.