summaryrefslogtreecommitdiff
path: root/pkg/api/handlers/libpod/healthcheck.go
blob: 6c74500b9e430309776b7456ed950048858234b8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
package libpod

import (
	"net/http"

	"github.com/containers/libpod/libpod"
	"github.com/containers/libpod/pkg/api/handlers/utils"
)

func RunHealthCheck(w http.ResponseWriter, r *http.Request) {
	runtime := r.Context().Value("runtime").(*libpod.Runtime)
	name := utils.GetName(r)
	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)
}