trpc
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.