Skip to content

Commit fc55cb4

Browse files
committed
#4 & #8 Generates swagger and http gateway libs
1 parent 1c6622a commit fc55cb4

File tree

12 files changed

+562
-29
lines changed

12 files changed

+562
-29
lines changed

example/hello-world-idl/Makefile

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
PROTOC_VERSION := 3.9.2
22
PROTOC_WEB_VERSION := 1.0.6
3+
34
PROTO_SOURCES := -I /usr/local/include
45
PROTO_SOURCES += -I .
56
PROTO_SOURCES += -I ${GOPATH}/src
67
PROTO_SOURCES += -I ${GOPATH}/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis
8+
PROTO_SOURCES += -I ${GOPATH}/src/github.com/grpc-ecosystem/grpc-gateway
79

8-
deps-linux: deps-protoc-linux deps-grpc-web-linux
10+
deps-linux: deps-protoc-linux deps-grpc-web-linux deps-go
911

1012
deps-protoc-linux:
1113
curl -OL https://github.com/google/protobuf/releases/download/v$(PROTOC_VERSION)/protoc-$(PROTOC_VERSION)-linux-x86_64.zip
@@ -19,9 +21,14 @@ deps-grpc-web-linux:
1921
sudo mv protoc-gen-grpc-web-$(PROTOC_WEB_VERSION)-linux-x86_64 /usr/local/bin/protoc-gen-grpc-web
2022
chmod +x /usr/local/bin/protoc-gen-grpc-web
2123

22-
generate: generate-grpc generate-web
24+
deps-go:
25+
go get -u github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway
26+
go get -u github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger
27+
go get -u github.com/golang/protobuf/protoc-gen-go
28+
29+
generate: generate-grpc generate-web generate-http
2330

24-
generate-grpc:
31+
generate-grpc:
2532
mkdir -p gen/go
2633
protoc ${PROTO_SOURCES} --go_out=plugins=grpc:./gen/go ./proto/health/*.proto
2734
protoc ${PROTO_SOURCES} --go_out=plugins=grpc:./gen/go ./proto/helloworld/*.proto
@@ -33,4 +40,11 @@ generate-web:
3340
protoc ${PROTO_SOURCES} --grpc-web_out=import_style=typescript,mode=grpcwebtext:gen/web ./proto/helloworld/*.proto
3441
cp -f -rv gen/web/proto/* gen/web
3542
rm -rf gen/web/Proto gen/web/proto
43+
generate-http:
44+
mkdir -p gen/http gen/swagger
45+
protoc ${PROTO_SOURCES} --grpc-gateway_out=logtostderr=true:gen/http --swagger_out=logtostderr=true:gen/swagger ./proto/health/*.proto
46+
protoc ${PROTO_SOURCES} --grpc-gateway_out=logtostderr=true:gen/http --swagger_out=logtostderr=true:gen/swagger ./proto/helloworld/*.proto
47+
cp -f -rv gen/http/proto/* gen/http
48+
cp -f -rv gen/swagger/proto/* gen/swagger
49+
rm -rf gen/swagger/proto
3650

example/hello-world-idl/gen/go/health/health.pb.go

Lines changed: 24 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

example/hello-world-idl/gen/http/health/health.pb.gw.go

Lines changed: 159 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)