This repository provides examples demonstrating the capabilities of the gRPC API Gateway project.
You can either install all the required tools locally to run the project containing the examples or use a Docker container to quickly try things out without setting up a local environment.
To build and run the Docker container, execute:
make docker-build && make docker-runIf you haven't installed protoc yet, follow the installation instructions here.
To install the necessary protoc plug-ins, run:
make install-toolsBuf is a powerful tool for protocol buffer code generation. If you have Buf installed or wish to install and use it, you can generate the required files with:
make generateAlternatively, you can use protoc directly. Note that this approach will download some required proto files:
make generate-protocThis example includes a UI accessible at http://localhost:4000/web. You can open multiple tabs to simulate multiple users interacting with the application. It serves as a simple demonstration of long-lived WebSocket integration.
Refer to the following files for this example:
chat_service.gochat_service.protochat_service_gateway.yaml
This example showcases a unary user endpoint and an SSE-based user event stream.
Relevant files for this example:
user_service.gouser_service.proto
You can test this example using the following cURL commands:
- Test the SSE user event stream endpoint, you should be receiving the updates as they come:
curl -N http://localhost:4000/users-stream- Add a new user:
curl -X POST http://localhost:4000/users --data '{"name": "Something"}'- Delete the user:
curl -X DELETE http://localhost:4000/users/:id