code: func (h *Handler) servePutLeader(w http.ResponseWriter, r *http.Request, params httprouter.Params) {
  	// Retrieve path parameters.
  	service := params.ByName("service")
  
  	// Check if the service allows manual leader election.
  	config := h.Store.Config(service)
  	if config == nil || config.LeaderType != discoverd.LeaderTypeManual {
  		hh.ValidationError(w, "", "service leader election type is not manual")
  		return
  	}
  
  	// Read instance from the request.
  	inst := &discoverd.Instance{}
  	if err := hh.DecodeJSON(r, inst); err != nil {
  		hh.Error(w, err)
  		return
  	}
  
  	// Manually set the leader on the service.
  	if err := h.Store.SetServiceLeader(service, inst.ID); err == ErrNotLeader {
  		h.redirectToLeader(w, r)
  		return
  	} else if err != nil {
  		hh.Error(w, err)
  		return
  	}
  }
docs: // servePutLeader sets the leader for a service.