So far, we have explicitly called a backend service by name and a method to access it. In this recipe, we will learn how we can access the services using Go Micro API, which implements an API gateway pattern to provide a single entry point to the microservices. The advantage of using Go Micro API is that it serves over HTTP and dynamically routes to the appropriate backend service using HTTP handlers.
Creating your Micro API
Getting ready...
Start consul agent, micro API, first-greeting-service.go, and second-greeting-service.go in separate terminals by executing the following commands:
$ consul agent -dev
$ micro api
$ go run first-greeting-service.go
$ go run second-greeting-service.go