Sha256: b9a65573593e8673d9855ec51f99bdddc661cf8bb412cc6a0965d0d348c845d9
Contents?: true
Size: 756 Bytes
Versions: 3
Compression:
Stored size: 756 Bytes
Contents
package handlers import ( "encoding/json" "net/http" log "github.com/Sirupsen/logrus" ) const kTagHealth = "HealthHandler" type HealthResponse struct { StatusMessage string `json:"status_message"` } type healthHandlerDependencies struct { logger *log.Logger } type healthHandler struct { deps healthHandlerDependencies } func (h *healthHandler) ServeHTTP(rw http.ResponseWriter, r *http.Request) { // all HealthHandlerDependencies are automatically created by injection process h.deps.logger.WithField(kTagHealth, "Called GET") response := HealthResponse{StatusMessage: "OK"} encoder := json.NewEncoder(rw) encoder.Encode(&response) } func newHealthHandler(deps healthHandlerDependencies) http.Handler { return &healthHandler{deps} }
Version data entries
3 entries across 3 versions & 1 rubygems