code: func (c *Client) Register(id, addr string) (*Response, error) {
  	m := map[string]string{
  		"addr": addr,
  	}
  
  	url := c.registrationURL(c.url, id)
  	client := &http.Client{}
  	client.CheckRedirect = func(req *http.Request, via []*http.Request) error {
  		return http.ErrUseLastResponse
  	}
  
  	for {
  		b, err := json.Marshal(m)
  		if err != nil {
  			return nil, err
  		}
  
  		c.logger.Printf("discovery client attempting registration of %s at %s", addr, url)
  		resp, err := client.Post(url, "application-type/json", bytes.NewReader(b))
  		if err != nil {
  			return nil, err
  		}
  		defer resp.Body.Close()
  
  		b, err = ioutil.ReadAll(resp.Body)
  		if err != nil {
  			return nil, err
  		}
  
  		switch resp.StatusCode {
  		case http.StatusOK:
  			r := &Response{}
  			if err := json.Unmarshal(b, r); err != nil {
  				return nil, err
  			}
  			c.logger.Printf("discovery client successfully registered %s at %s", addr, url)
  			return r, nil
  		case http.StatusMovedPermanently:
  			url = resp.Header.Get("location")
  			c.logger.Println("discovery client redirecting to", url)
  			continue
  		default:
  			return nil, errors.New(resp.Status)
  		}
  	}
  }
docs: // Register attempts to register with the Discovery Service, using the given
  // address.