aboutsummaryrefslogtreecommitdiff
path: root/pkg/api/handlers/libpod/healthcheck.go
blob: 0d7bf3ea75be02e163737b9974c7f6f283cd3d19 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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)
}