code: func eventCountByDeviceIdHandler(w http.ResponseWriter, r *http.Request) {
  	defer r.Body.Close()
  
  	vars := mux.Vars(r)
  	id, err := url.QueryUnescape(vars["deviceId"])
  	ctx := r.Context()
  
  	if err != nil {
  		http.Error(w, err.Error(), http.StatusBadRequest)
  		LoggingClient.Error("Problem unescaping URL: " + err.Error())
  		return
  	}
  
  	// Check device
  	count, err := countEventsByDevice(id, ctx)
  	if err != nil {
  		LoggingClient.Error(fmt.Sprintf("error checking device %s %v", id, err))
  		switch err := err.(type) {
  		case *types.ErrServiceClient:
  			http.Error(w, err.Error(), err.StatusCode)
  			return
  		default: //return an error on everything else.
  			http.Error(w, err.Error(), http.StatusInternalServerError)
  			return
  		}
  	}
  
  	w.WriteHeader(http.StatusOK)
  	w.Write([]byte(strconv.Itoa(count)))
  }
docs: /*
  Return number of events for a given device in Core Data
  deviceID - ID of the device to get count for
  /api/v1/event/count/{deviceId}
  */