code: func (h *Handler) servePutInstance(w http.ResponseWriter, r *http.Request, params httprouter.Params) {
  	// Read path parameter.
  	service := params.ByName("service")
  
  	// Read instance from request.
  	inst := &discoverd.Instance{}
  	if err := json.NewDecoder(r.Body).Decode(inst); err != nil {
  		hh.Error(w, err)
  		return
  	}
  
  	// Ensure instance is valid.
  	if err := inst.Valid(); err != nil {
  		hh.ValidationError(w, "", err.Error())
  		return
  	}
  
  	// Add instance to service in the store.
  	if err := h.Store.AddInstance(service, inst); err == ErrNotLeader {
  		h.redirectToLeader(w, r)
  		return
  	} else if IsNotFound(err) {
  		hh.ObjectNotFoundError(w, err.Error())
  		return
  	} else if err != nil {
  		hh.Error(w, err)
  		return
  	}
  }
docs: // servePutInstance adds an instance to a service.