😮 A surprisingly easy API server and generator in gRPC and Go
- You can develop and deploy API servers blazingly fast âš¡
- Easy code generator
- application (inspired by
rails new
andcreate-react-app
) - gRPC services and their implementations (inspired by
rails g (scaffold_)controller
)
- application (inspired by
- User-friendly
protoc
wrapper (inspired by protoeasy) - Provides gRPC and HTTP JSON API with single implementation by using grpc-gateway
- Generates codes based on google's API design guideline
$ brew install protobuf
$ brew install izumin5210/tools/grapi
You should install protoc
command from google/protobuf.
- Linux:
curl -Lo grapi https://github.com/izumin5210/grapi/releases/download/v0.2.2/grapi_linux_amd64 && chmod +x grapi && sudo mv grapi /usr/local/bin
- masOS:
curl -Lo grapi https://github.com/izumin5210/grapi/releases/download/v0.2.2/grapi_darwin_amd64 && chmod +x grapi && sudo mv grapi /usr/local/bin
$ grapi init awesome-app
$ grapi g service books
Or, if you need full standard methods, you can get them with following command:
$ grapi g scaffold-service books
And you should register generated services to the grapiserver.Engine
instance:
// app/run.go
// Run starts the grapiserver.
func Run() error {
s := grapiserver.New(
grapiserver.WithDefaultLogger(),
grapiserver.WithServers(
+ server.NewBookServiceServer(),
- // TODO
),
)
return s.Serve()
}
If you updated service definition, you can re-generate .pb.go
and .pb.gw.go
with following command:
$ grapi protoc
$ grapi server
$ grapi g command import-books
$ vim cmd/import-books/run.go # implements the command
$ grapi import-books # run the command
$ grapi build