Skip to content

alanchchen/go-example-twirp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go-example-twirp

Go example for Twitch's Twirp RPC framework

What is Twirp

Twirp is a framework for service-to-service communication emphasizing simplicity and minimalism. It generates routing and serialization from API definition files and lets you focus on your application's logic instead of thinking about folderol like HTTP methods and paths and JSON.

See Twirp official repository.

Introduction

All executables are located at the cmd directory.

Examples

There are 5 examples:

  • Clients
    • grpc-client: Can connect to grpc-server and hybrid-server
    • twirp-client: Can connect to twirp-server and hybrid-server
  • Servers
    • grpc-server: Can be connected by grpc-client
    • twirp-server: Can be connected by twirp-client and cURL
    • hybrid-server: Can be connected by grpc-client, twirp-client and cURL

Usage

Run server

$ ./build/bin/grpc-server

or

$ ./build/bin/twirp-server

or

$ ./build/bin/hybrid-server

Run client

$ ./build/bin/grpc-client

or

$ ./build/bin/twirp-client

cURL example

HTTP endpoints: http://host:port/twirp/am.is.PetstoreService/<method>

$ curl -s -XPOST http://localhost:8000/twirp/am.is.PetstoreService/AddPet --header "Content-Type:application/json" --data '{"pet": {"name": "Test"}}' | jq

Output

{
  "name": "Test"
}

Development

Build all executables

$ make all

Generate code from protobuf

$ make gen

Clean all executables

$ make clean

Run go test

$ make test

Run dep ensure

$ make deps

Docker

Build docker image

$ make docker

Push docker image

$ make docker-push

Note: Be sure to set DOCKER_REPOSITORY in Makefile for your own before building and pushing the docker image.

License

The MIT License

About

Go example for Twitch's Twirp RPC framework

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published