Skip to content

vertx-howtos/grpc-web-howto

Repository files navigation

Building a gRPC Web service

Build Status

This document will show you how to build a browser/server application with Vert.x and gRPC Web.

What you will build

The application involves a client, the browser, and a Vert.x server:

  • the user types a name in a text field and clicks the send button

  • the browser sends the name to the server using the gRPC Web protocol

  • the server replies with a greeting

  • the browser displays the greeting

On the server side, you will create a Vert.x gRPC server service that:

  • implements a gRPC server stub

  • configures an HTTP server replying to both gRPC Web and static file requests

On the client side, you will create a web page that uses the gRPC Web Javascript client.

run

What you need

The protoc Javascript and gRPC Web plugin files must be installed somewhere on your PATH and be executable.

Tip

On several Linux-like systems, you can install the plugins like this:

mkdir --parents "$HOME/.local/bin" curl -sL https://github.com/protocolbuffers/protobuf-javascript/releases/download/v3.21.4/protobuf-javascript-3.21.4-linux-x86_64.tar.gz | tar xzfO - bin/protoc-gen-js > "$HOME/.local/bin/protoc-gen-js" chmod u+x "$HOME/.local/bin/protoc-gen-js" curl -sL https://github.com/grpc/grpc-web/releases/download/1.5.0/protoc-gen-grpc-web-1.5.0-linux-x86_64 > "$HOME/.local/bin/protoc-gen-grpc-web" chmod u+x "$HOME/.local/bin/protoc-gen-grpc-web"

You don’t have to install protoc or the Java plugin. They will be managed by a Maven plugin.

Create the project

gRPC service definition

The gRPC Greeter service consists in a single SayHello rpc method. The HelloRequest message contains the name sent by the client. The HelloReply message contains the greeting generated by the server.

About

Building a gRPC Web service

Topics

Resources

License

Stars

Watchers

Forks

Contributors 2

  •  
  •