summaryrefslogtreecommitdiff
path: root/pkg/api/handlers/libpod/healthcheck.go
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/api/handlers/libpod/healthcheck.go')
-rw-r--r--pkg/api/handlers/libpod/healthcheck.go25
1 files changed, 25 insertions, 0 deletions
diff --git a/pkg/api/handlers/libpod/healthcheck.go b/pkg/api/handlers/libpod/healthcheck.go
new file mode 100644
index 000000000..0d7bf3ea7
--- /dev/null
+++ b/pkg/api/handlers/libpod/healthcheck.go
@@ -0,0 +1,25 @@
+package libpod
+
+import (
+ "net/http"
+
+ "github.com/containers/libpod/libpod"
+ "github.com/containers/libpod/pkg/api/handlers/utils"
+ "github.com/gorilla/mux"
+)
+
+func RunHealthCheck(w http.ResponseWriter, r *http.Request) {
+ // 200 ok
+ // 404 no such
+ // 500 internal
+ runtime := r.Context().Value("runtime").(*libpod.Runtime)
+ name := mux.Vars(r)["name"]
+ status, err := runtime.HealthCheck(name)
+ if err != nil {
+ if status == libpod.HealthCheckContainerNotFound {
+ utils.ContainerNotFound(w, name, err)
+ }
+ utils.InternalServerError(w, err)
+ }
+ utils.WriteResponse(w, http.StatusOK, status)
+}