Solution 2: Working with gRPC

Let’s solve the challenge set in the previous lesson.

We'll cover the following

Solution

Here is the updated gServer.go code converted into a RESTful server. We have a RESTful server that listens on the specified port and provides the same functionality as the gRPC server but using HTTP endpoints. To access the endpoints using HTTP GET requests, open a new terminal window and copy and paste the curl commands below:

  • To get the date: curl http://localhost:8080/getdate

  • To get a random number: curl http://localhost:8080/getrandom?seed=123\&place=2

  • To get a random password: curl http://localhost:8080/getrandompass?seed=456\&length=10

Get hands-on with 1400+ tech skills courses.