2021-01-10 15:31:37 +08:00
|
|
|
.PHONY:all
|
|
|
|
|
|
|
|
clean:
|
2021-01-16 16:28:32 +08:00
|
|
|
rm -rf ./gen/proto* /gen/openapi2/*
|
2021-01-10 15:31:37 +08:00
|
|
|
|
|
|
|
gofmt:
|
2021-01-16 16:28:32 +08:00
|
|
|
find . -name "*.go" \
|
|
|
|
-not -path "./gen" \
|
|
|
|
-not -path ".git/*" \
|
|
|
|
| xargs gofmt -s -d -w
|
2021-01-10 15:31:37 +08:00
|
|
|
|
|
|
|
all:
|
|
|
|
protoc \
|
2021-01-16 16:28:32 +08:00
|
|
|
--proto_path ./protos \
|
|
|
|
--go_out ./gen/proto --go_opt paths=source_relative \
|
|
|
|
--go-grpc_out ./gen/proto --go-grpc_opt paths=source_relative \
|
|
|
|
--grpc-gateway_out ./gen/proto \
|
2021-01-10 15:31:37 +08:00
|
|
|
--grpc-gateway_opt paths=source_relative \
|
|
|
|
--grpc-gateway_opt logtostderr=true \
|
|
|
|
--grpc-gateway_opt generate_unbound_methods=true \
|
2021-01-16 16:28:32 +08:00
|
|
|
--openapiv2_out ./gen/openapi2 \
|
2021-01-10 15:31:37 +08:00
|
|
|
--openapiv2_opt logtostderr=true \
|
2021-01-16 16:28:32 +08:00
|
|
|
./protos/echo/v1/echo.proto
|
2021-01-10 15:31:37 +08:00
|
|
|
|
|
|
|
grpc:
|
|
|
|
protoc \
|
2021-01-16 16:28:32 +08:00
|
|
|
--proto_path ./protos \
|
|
|
|
--go_out ./gen/proto --go_opt paths=source_relative \
|
|
|
|
--go-grpc_out ./gen/proto --go-grpc_opt paths=source_relative \
|
|
|
|
./protos/echo/v1/echo.proto
|
2021-01-10 15:31:37 +08:00
|
|
|
|
|
|
|
gateway:
|
|
|
|
protoc \
|
2021-01-16 16:28:32 +08:00
|
|
|
--proto_path ./protos \
|
|
|
|
--grpc-gateway_out ./gen/proto \
|
2021-01-10 15:31:37 +08:00
|
|
|
--grpc-gateway_opt paths=source_relative \
|
|
|
|
--grpc-gateway_opt logtostderr=true \
|
|
|
|
--grpc-gateway_opt generate_unbound_methods=true \
|
2021-01-16 16:28:32 +08:00
|
|
|
./protos/echo/v1/echo.proto
|
2021-01-10 15:31:37 +08:00
|
|
|
|
|
|
|
openapi:
|
|
|
|
protoc \
|
2021-01-16 16:28:32 +08:00
|
|
|
--proto_path ./protos \
|
|
|
|
--openapiv2_out ./gen/openapi2 \
|
2021-01-10 15:31:37 +08:00
|
|
|
--openapiv2_opt logtostderr=true \
|
2021-01-16 16:28:32 +08:00
|
|
|
/protos/echo/v1/echo.proto
|
2021-01-17 05:25:49 +08:00
|
|
|
|
|
|
|
certs:
|
|
|
|
openssl genrsa -out ca.key 2048
|
|
|
|
openssl req -new -x509 -days 3650 \
|
|
|
|
-subj "/C=GB/L=China/O=gobook/CN=github.com" \
|
|
|
|
-key ca.key -out ca.crt
|
|
|
|
openssl req -new \
|
|
|
|
-subj "/C=GB/L=China/O=server/CN=server.io" \
|
|
|
|
-key server.key \
|
|
|
|
-out server.csr
|
|
|
|
openssl x509 -req -sha256 \
|
|
|
|
-CA ca.crt -CAkey ca.key -CAcreateserial -days 3650 \
|
|
|
|
-in server.csr \
|
|
|
|
-out server.crt
|
|
|
|
openssl req -new \
|
|
|
|
-subj "/C=GB/L=China/O=client/CN=client.io" \
|
|
|
|
-key client.key \
|
|
|
|
-out client.csr
|
|
|
|
openssl x509 -req -sha256 \
|
|
|
|
-CA ca.crt -CAkey ca.key -CAcreateserial -days 3650 \
|
|
|
|
-in client.csr \
|
|
|
|
-out client.crt
|