Coder Social home page Coder Social logo

go-example-twirp's Introduction

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

go-example-twirp's People

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.