- 1.5以上
$git clone https://github.com/google/protobuf
$cd protobuf
$./autogen.sh
$./configure
$make
$make check
#make install
go get -u github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway
go get -u github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger
go get -u github.com/golang/protobuf/{proto,protoc-gen-go}
go get google.golang.org/grpc
.
├── gateway
│ └── main.go
├── greeter_client
│ └── main.go
├── greeter_server
│ └── main.go
├── proto
│ ├── google
│ │ └── api
│ │ ├── annotations.pb.go
│ │ ├── annotations.proto
│ │ ├── http.pb.go
│ │ └── http.proto
│ ├── helloworld.pb.go
│ ├── helloworld.pb.gw.go
│ ├── helloworld.proto
│ └── Makefile
└── README.md
- 问题protoc-gen-grpc-gateway中第三方的google api报错
helloworld.proto,注意googleapi写法
cd proto && make
$cd greeter_server && go run main.go
$cd gateway && go run main.go
$curl -X POST -k http://localhost:8080/v1/example/echo -d '{"name": " world"}'