github.com/prebid/prebid-server/v2@v2.18.0/endpoints/status.go (about)

     1  package endpoints
     2  
     3  import (
     4  	"net/http"
     5  
     6  	"github.com/julienschmidt/httprouter"
     7  )
     8  
     9  // NewStatusEndpoint returns a handler which writes the given response when the app is ready to serve requests.
    10  func NewStatusEndpoint(response string) httprouter.Handle {
    11  	// Today, the app always considers itself ready to serve requests.
    12  	if response == "" {
    13  		return func(w http.ResponseWriter, _ *http.Request, _ httprouter.Params) {
    14  			w.WriteHeader(http.StatusNoContent)
    15  		}
    16  	}
    17  
    18  	responseBytes := []byte(response)
    19  	return func(w http.ResponseWriter, _ *http.Request, _ httprouter.Params) {
    20  		w.Write(responseBytes)
    21  	}
    22  }