How it works...

Once we run the program, the RPC server will start locally listening on port 8080.

Next, execute a POST request from the command line as follows:

$ curl -X POST -H 'Content-Type: application/json' -d '{"service": "go.micro.service.greeter", "method": "Say.Hello", "request": {"name": "Arpit Aggarwal"}}' http://localhost:8080/rpc

This will give us Hello followed by the name as a response from the server as shown in the following screenshot:

Looking at the logs of the first-greeting-service.go will show us that the request is served by the first greeting service, as follows:

Let’s look at the program we have written:

  • Using ...

Get Go Web Development Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.