healthcheck.go 703 B

123456789101112131415161718192021222324252627
  1. // SPDX-FileCopyrightText: Copyright The Miniflux Authors. All rights reserved.
  2. // SPDX-License-Identifier: Apache-2.0
  3. package server // import "miniflux.app/v2/internal/http/server"
  4. import (
  5. "fmt"
  6. "net/http"
  7. "miniflux.app/v2/internal/storage"
  8. )
  9. func livenessProbe(w http.ResponseWriter, r *http.Request) {
  10. w.WriteHeader(http.StatusOK)
  11. w.Write([]byte("OK"))
  12. }
  13. func newReadinessProbe(store *storage.Storage) http.HandlerFunc {
  14. return func(w http.ResponseWriter, r *http.Request) {
  15. if err := store.Ping(); err != nil {
  16. http.Error(w, fmt.Sprintf("Database Connection Error: %q", err), http.StatusServiceUnavailable)
  17. return
  18. }
  19. w.WriteHeader(http.StatusOK)
  20. w.Write([]byte("OK"))
  21. }
  22. }