Exercise 2: Working with gRPC

Let’s test our understanding by attempting this challenge.

We'll cover the following

Let’s practice what we’ve learned so far. The solution to this exercise will be provided in the next lesson.

Problem

Try to convert gServer.go into a RESTful server. The RESTful server should listen on a specified port and provide the same functionality as the gRPC server but using HTTP endpoints. Upon updating the code, to access the endpoints using HTTP GET requests, open a new terminal window and execute the following curl commands:

  • 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 1200+ tech skills courses.