github.com/containers/libpod@v1.9.4-0.20220419124438-4284fd425507/pkg/api/handlers/compat/ping.go (about) 1 package compat 2 3 import ( 4 "fmt" 5 "net/http" 6 7 "github.com/containers/buildah" 8 "github.com/containers/libpod/pkg/api/handlers" 9 ) 10 11 // Ping returns headers to client about the service 12 // 13 // This handler must always be the same for the compatibility and libpod URL trees! 14 // Clients will use the Header availability to test which backend engine is in use. 15 func Ping(w http.ResponseWriter, r *http.Request) { 16 w.Header().Set("API-Version", handlers.DefaultApiVersion) 17 w.Header().Set("BuildKit-Version", "") 18 w.Header().Set("Docker-Experimental", "true") 19 w.Header().Set("Cache-Control", "no-cache") 20 w.Header().Set("Pragma", "no-cache") 21 22 // API-Version and Libpod-API-Version may not always be equal 23 w.Header().Set("Libpod-API-Version", handlers.DefaultApiVersion) 24 w.Header().Set("Libpod-Buildha-Version", buildah.Version) 25 w.WriteHeader(http.StatusOK) 26 27 if r.Method == http.MethodGet { 28 fmt.Fprint(w, "OK") 29 } 30 fmt.Fprint(w, "\n") 31 }