code: func deleteByDeviceIdHandler(w http.ResponseWriter, r *http.Request) {
  	defer r.Body.Close()
  
  	vars := mux.Vars(r)
  	deviceId, err := url.QueryUnescape(vars["deviceId"])
  	ctx := r.Context()
  
  	// Problems unescaping URL
  	if err != nil {
  		http.Error(w, err.Error(), http.StatusBadRequest)
  		LoggingClient.Error("Error unescaping the URL: " + err.Error())
  		return
  	}
  
  	// Check device
  	if err := checkDevice(deviceId, ctx); err != nil {
  		LoggingClient.Error(fmt.Sprintf("error checking device %s %v", deviceId, 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
  		}
  	}
  
  	switch r.Method {
  	case http.MethodDelete:
  		count, err := deleteEvents(deviceId)
  		if err != nil {
  			http.Error(w, err.Error(), http.StatusInternalServerError)
  			return
  		}
  
  		w.Header().Set("Content-Type", "application/json")
  		w.WriteHeader(http.StatusOK)
  		w.Write([]byte(strconv.Itoa(count)))
  	}
  }
docs: // Delete all of the events associated with a device
  // api/v1/event/device/{deviceId}
  // 404 - device ID not found in metadata
  // 503 - service unavailable