Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Dockerfile.app
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
26 changes: 10 additions & 16 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,14 @@ Install MongoDB and make sure it's running on localhost:27017

`dep status` && `dep ensure`

## Generate gRPC stub
- Generating client and server code
## Generate gRPC stub :
Generating client and server code and 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 \
--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
`make`

## Start Server

`go run server/*.go`
`go run main.go`
`go run gateway/main.go`

## Example API Calls
Expand Down Expand Up @@ -58,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`
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion gateway/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down