github.com/jxgolibs/go-oauth2-server@v1.0.1/health/handlers.go (about) 1 package health 2 3 import ( 4 "net/http" 5 6 "github.com/RichardKnop/go-oauth2-server/util/response" 7 ) 8 9 // Handles health check requests (GET /v1/health) 10 func (s *Service) healthcheck(w http.ResponseWriter, r *http.Request) { 11 rows, err := s.db.Raw("SELECT 1=1").Rows() 12 defer rows.Close() 13 14 var healthy bool 15 if err == nil { 16 healthy = true 17 } 18 19 response.WriteJSON(w, map[string]interface{}{ 20 "healthy": healthy, 21 }, 200) 22 }