Skip to content
Open
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
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Please treat the services provided as if they would live in a real-world environ

- `api`: A basic REST gateway, forwarding requests onto service(s).
- [`racing`](racing/README.md): A very bare-bones racing service.
- [`sports`](sports/README.md): A service for sporting events.

```
entain/
Expand All @@ -19,6 +20,12 @@ entain/
│ ├─ proto/
│ ├─ service/
│ ├─ main.go
├─ sports/
│ ├─ db/
│ ├─ proto/
│ ├─ service/
│ ├─ main.go/
│ ├─ README.md
├─ README.md
```

Expand Down
20 changes: 17 additions & 3 deletions api/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,19 @@ import (
"net/http"

"github.com/ashleyjlive/entain/api/proto/racing"
"github.com/ashleyjlive/entain/api/proto/sports"
"github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
log "github.com/sirupsen/logrus"
"google.golang.org/grpc"
)

var (
apiEndpoint = flag.String("api-endpoint", "localhost:8000", "API endpoint")
grpcEndpoint = flag.String("grpc-endpoint", "localhost:9000", "gRPC server endpoint")
apiEndpoint = flag.String("api-endpoint", "localhost:8000",
"API endpoint")
racingGrpcEndpoint = flag.String("racing-grpc-endpoint", "localhost:9000",
"gRPC server endpoint for racing service")
sportsGrpcEndpoint = flag.String("sports-grpc-endpoint", "localhost:10000",
"gRPC server endpoint for sports service")
)

func main() {
Expand All @@ -33,7 +38,16 @@ func run() error {
if err := racing.RegisterRacingHandlerFromEndpoint(
ctx,
mux,
*grpcEndpoint,
*racingGrpcEndpoint,
[]grpc.DialOption{grpc.WithInsecure()},
); err != nil {
return err
}

if err := sports.RegisterSportsHandlerFromEndpoint(
ctx,
mux,
*sportsGrpcEndpoint,
[]grpc.DialOption{grpc.WithInsecure()},
); err != nil {
return err
Expand Down
1 change: 1 addition & 0 deletions api/proto/api.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
package proto

//go:generate protoc -I . --go_out . --go_opt paths=source_relative --go-grpc_out . --go-grpc_opt paths=source_relative --grpc-gateway_out . --grpc-gateway_opt paths=source_relative racing/racing.proto
//go:generate protoc -I . --go_out . --go_opt paths=source_relative --go-grpc_out . --go-grpc_opt paths=source_relative --grpc-gateway_out . --grpc-gateway_opt paths=source_relative sports/sports.proto
Loading