github.com/xmidt-org/webpa-common@v1.11.9/xhttp/gate/status.go (about)

     1  package gate
     2  
     3  import (
     4  	"fmt"
     5  	"net/http"
     6  	"time"
     7  )
     8  
     9  // Status is an http.Handler that reports the status of a gate
    10  type Status struct {
    11  	Gate Interface
    12  }
    13  
    14  func (s *Status) ServeHTTP(response http.ResponseWriter, request *http.Request) {
    15  	response.Header().Set("Content-Type", "application/json")
    16  	state, timestamp := s.Gate.State()
    17  	fmt.Fprintf(response, `{"open": %t, "timestamp": "%s"}`, state, timestamp.Format(time.RFC3339))
    18  }