GopherJS Client and gRPC Server - Part 2

A guide to implementing a GopherJS frontend to a gRPC backend exposed over HTTP via the gRPC-gateway

Implement the server I like to start by creating a struct and write a simple definition that’ll immediately fail to compile. package server import ( "github.com/johanbrandhorst/gopherjs-grpc-websocket/protos/server" ) type Server struct{} var _ server.MyServerServer = &Server{} This won’t compile, because the Server struct does not implement the server.MyServerServer interface. But it’ll also tell us what we’ve got left to implement. So lets implement the server methods: func (s Server) Simple(ctx context. [Read More]

GopherJS Client and gRPC Server - Part 1

A guide to implementing a GopherJS frontend to a gRPC backend exposed over HTTP via the gRPC-gateway

Create the protobuf interface We’ll start by creating a folder for the package we want to create. Lets call it server. Next we type up a .proto file to define the interface between the server and the client. We’ll have to include some extra proto annotations in order to have the gRPC-gateway generate the translations methods we need. Lets define a simple service with a single HTTP GET endpoint: [Read More]

GopherJS Client and gRPC Server - Introduction

A guide to implementing a GopherJS frontend to a gRPC backend exposed over HTTP via the gRPC-gateway

I’ve been using gRPC and Go a lot in the last year. At Cognitive Logic every one of our backend services is implemented with Go and gRPC, and it enables us to abstract away most of the complexities of networked micro services and keep interfaces typed and well defined using Google protobuffers. I really enjoy using both, but sometimes I need to write a frontend to a web server and I despise writing Javascript. [Read More]