github.com/containers/podman/v2@v2.2.2-0.20210501105131-c1e07d070c4c/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  )
     9  
    10  // Ping returns headers to client about the service
    11  //
    12  // This handler must always be the same for the compatibility and libpod URL trees!
    13  // Clients will use the Header availability to test which backend engine is in use.
    14  // Note: Additionally handler supports GET and HEAD methods
    15  func Ping(w http.ResponseWriter, r *http.Request) {
    16  	// Note API-Version and Libpod-API-Version are set in handler_api.go
    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  	w.Header().Set("Libpod-Buildah-Version", buildah.Version)
    23  	w.WriteHeader(http.StatusOK)
    24  
    25  	if r.Method == http.MethodGet {
    26  		fmt.Fprint(w, "OK")
    27  	}
    28  }