This is a sample Twirp service that demonstrates how to use Twirp to build a simple RPC (Remote Procedure Call) service using twitchtv/twirp.
To install and run the Twirp service, follow these steps:
- Clone the repository.
- Open the project in VScode dev containers using the following steps:
- Click on Remote Explorer VS code extention.
- Select "Dev Containers" from the top dropdown list.
- Once you have the project open in VS Code, click on the "+" icon at the top-right corner of the window, and select "Open Currrent Folder in Container" from the menu.
- Once the dev container is built and running, you'll be working in a fully configured development environment. You can start coding, running, and debugging your project as you normally would.
Tip
Remember, any changes you make inside the dev container will also be reflected in your local project directory, since the dev container shares its filesystem with your local project directory.
- Build the project and install tools using
make
command. This will install all tools, dependencies and build the project. - Run the server using
./bin/twirp-server
or using the 'Run and Debug' launch menu in VS code.
Important
You need to re-build the files and restart the server if you have done any code changes in the project.
./bin/twirp-client
Once the service is running, you can make RPC requests to it using a Twirp client. Here's an example using cURL:
curl -X POST \
-H 'Content-Type: application/json' \
-d '{"inches": 10}' \
http://localhost:8080/twirp/service.Haberdasher/MakeHat | jq