trpc

module
v1.0.0-alpha Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 21, 2021 License: Apache-2.0

README

trpc

Go Reference

A collection of helpers & simple foundation framework for working with Twirp. Twirp is a rpc framework on top of HTTP 1.1 and ProtocolBuffers which provide simplicity. Working with Twirp is almost like working with HTTP REST JSON API, but it's more structured via ProtocolBuffers, but still simpler rather than gRPC.


Adapters

This repo provides a simple framework which handle pluggable adapters which is basically used to muxing http requests. Available adapters are:

Usage

Use default mux:

func main() {
	server := &service.Server{} // implements Haberdasher interface
	twirpHandler := haberdasher.NewHaberdasherServer(server)

	engine := adapter.NewDefault()
	trpc := framework.New(engine)
	trpc.Register(twirpHandler)
	trpc.Run(":8080")
}

Use gorilla:

func main() {
	server := &service.Server{} // implements Haberdasher interface
	twirpHandler := haberdasher.NewHaberdasherServer(server)

	engine := adapter.NewGorilla()
	trpc := framework.New(engine)
	trpc.Register(twirpHandler)
	trpc.Run(":8080")
}

Use fiber:

func main() {
	server := &service.Server{} // implements Haberdasher interface
	twirpHandler := haberdasher.NewHaberdasherServer(server)

	engine := adapter.NewFiber()
	trpc := framework.New(engine)
	trpc.Register(twirpHandler)
	trpc.Run(":8080")
}

You can play with example, for client/server example usages.

Directories

Path Synopsis
example
pkg

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL