From 7e70050bc4a34188674c41570f73af43e3918530 Mon Sep 17 00:00:00 2001 From: Trinh Dai Phuc <1653068@student.hcmus.edu.vn> Date: Sun, 8 Mar 2020 10:11:50 +0700 Subject: [PATCH 1/3] Change env server host and readme --- Dockerfile.app | 2 +- Readme.md | 20 ++++---------------- docker-compose.yml | 2 +- gateway/main.go | 2 +- 4 files changed, 7 insertions(+), 19 deletions(-) diff --git a/Dockerfile.app b/Dockerfile.app index 70be3f87..7d2f0cc7 100644 --- a/Dockerfile.app +++ b/Dockerfile.app @@ -9,7 +9,7 @@ ADD . /app/src WORKDIR /app/src -RUN go build -o bin/server server/*.go +RUN go build -o bin/server main.go FROM alpine:3.10 WORKDIR /app diff --git a/Readme.md b/Readme.md index 1a51c99b..f9ad75b8 100644 --- a/Readme.md +++ b/Readme.md @@ -9,22 +9,10 @@ Install MongoDB and make sure it's running on localhost:27017 `dep status` && `dep ensure` -## Generate gRPC stub -- Generating client and server code - - protoc -I/usr/local/include -I. \ - -I$GOPATH/src \ - -I$GOPATH/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis \ - --go_out=Mgoogle/api/annotations.proto=github.com/gengo/grpc-gateway/third_party/googleapis/google/api,plugins=grpc:. \ - protos/entity.proto - -- Generate reverse-proxy for your RESTful API: - - protoc -I/usr/local/include -I. \ - -I$GOPATH/src \ - -I$GOPATH/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis \ - --grpc-gateway_out=logtostderr=true:. \ - protos/entity.proto +## Generate gRPC stub : + Generating client and server code and reverse-proxy for your RESTful API: + +`make` ## Start Server diff --git a/docker-compose.yml b/docker-compose.yml index 190d616e..9c6a5c10 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -27,7 +27,7 @@ services: - 8080:8080 environment: - GRPC_VERBOSITY=debug - - SERVER_HOST=grpc_app:50051 + - ENTITY_SERVER_HOST=grpc_app:50051 mongo: image: "mongo:4.2.1" diff --git a/gateway/main.go b/gateway/main.go index 726e93db..ad4095cb 100644 --- a/gateway/main.go +++ b/gateway/main.go @@ -50,7 +50,7 @@ func RunEndPoint(address string, opts ...runtime.ServeMuxOption) error { dialOpts := []grpc.DialOption{grpc.WithInsecure()} err := godotenv.Load() - entityEndpoint := flag.String("entity_endpoint", os.Getenv("SERVER_HOST"), "endpoint of EntityService") + entityEndpoint := flag.String("entity_endpoint", os.Getenv("ENTITY_SERVER_HOST"), "endpoint of EntityService") err = pb.RegisterEntityServiceHandlerFromEndpoint(ctx, mux, *entityEndpoint, dialOpts) if err != nil { From 5ad2fedfff957311b3ec994b2902995474516ee6 Mon Sep 17 00:00:00 2001 From: Trinh Dai Phuc <1653068@student.hcmus.edu.vn> Date: Sun, 8 Mar 2020 10:24:00 +0700 Subject: [PATCH 2/3] fix readme generate code gRPC stub --- Readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Readme.md b/Readme.md index f9ad75b8..2229dec9 100644 --- a/Readme.md +++ b/Readme.md @@ -16,7 +16,7 @@ Install MongoDB and make sure it's running on localhost:27017 ## Start Server -`go run server/*.go` +`go run main.go` `go run gateway/main.go` ## Example API Calls From bbca762941b8aa84a77669b4643e78db3dc5e26d Mon Sep 17 00:00:00 2001 From: Trinh Dai Phuc <1653068@student.hcmus.edu.vn> Date: Sun, 8 Mar 2020 10:25:42 +0700 Subject: [PATCH 3/3] fix readme generate code gRPC stub --- Readme.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Readme.md b/Readme.md index 2229dec9..d6cd1c4d 100644 --- a/Readme.md +++ b/Readme.md @@ -46,3 +46,9 @@ Install MongoDB and make sure it's running on localhost:27017 - If you want to use Kong (https://konghq.com/kong/) as API gateway. You can checkout to banch kong-api-gw `git checkout kong-api-gw` + +## USE ENVOY AS API GATEWAY + +- If you want to use Kong (https://www.envoyproxy.io/) as API gateway. You can checkout to banch kong-api-gw + +`git checkout envoy`