code: func (h *Handler) servePutService(w http.ResponseWriter, r *http.Request, params httprouter.Params) {
  	// Retrieve the path parameter.
  	service := params.ByName("service")
  	if err := ValidServiceName(service); err != nil {
  		hh.ValidationError(w, "", err.Error())
  		return
  	}
  
  	// Read config from the request.
  	config := &discoverd.ServiceConfig{}
  	if err := hh.DecodeJSON(r, config); err != nil {
  		hh.Error(w, err)
  		return
  	}
  
  	// Add the service to the store.
  	if err := h.Store.AddService(service, config); err == ErrNotLeader {
  		h.redirectToLeader(w, r)
  		return
  	} else if IsServiceExists(err) {
  		hh.ObjectExistsError(w, err.Error())
  		return
  	} else if err != nil {
  		hh.Error(w, err)
  		return
  	}
  }
docs: // servePutService creates a service.