+// healthCheckHandler runs a few commands on the backend and returns
+// OK or not depending on the status of the backend
+func (h handler) healthCheckHandler(w http.ResponseWriter, r *http.Request) {
+
+ sealed, err := h.secretBackend.GetStatus()
+ if smslogger.CheckError(err, "HealthCheck") != nil {
+ http.Error(w, err.Error(), http.StatusInternalServerError)
+ return
+ }
+
+ // backend is sealed
+ if sealed == true {
+ http.Error(w, "Secret Backend is not ready for operations", http.StatusInternalServerError)
+ return
+ }
+
+ // backend is not sealed
+ dname, _ := uuid.GenerateUUID()
+ _, err = h.secretBackend.CreateSecretDomain(dname)
+ if smslogger.CheckError(err, "HealthCheck Create Domain") != nil {
+ http.Error(w, err.Error(), http.StatusInternalServerError)
+ return
+ }
+
+ err = h.secretBackend.DeleteSecretDomain(dname)
+ if smslogger.CheckError(err, "HealthCheck Delete Domain") != nil {
+ http.Error(w, err.Error(), http.StatusInternalServerError)
+ return
+ }
+
+ w.WriteHeader(http.StatusOK)
+}
+