How to do it...

  1. Create greeting-api.go inside the api directory by executing the command $ mkdir api && cd api && touch greeting-api.go.
  2. Copy the following content to greeting-api.go:
package mainimport (  "context"  "encoding/json"  "log"  "strings"  hello "../proto"  "github.com/micro/go-micro"  api "github.com/micro/micro/api/proto")type Say struct {  Client hello.SayClient}func (s *Say) Hello(ctx context.Context, req *api.Request, rsp *api.Response) error {  log.Print("Received Say.Hello request - Micro Greeter API")  name, ok := req.Get["name"]  if ok   {    response, err := s.Client.Hello    (      ctx, &hello.Request      {        Name: strings.Join(name.Values, " "),      }    )    if err != nil     {      return err    }    message, _ := json.Marshal    (      map[string]string      { "message": response.Msg, ...

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.