github.com/ethersphere/bee/v2@v2.2.0/pkg/api/health.go (about)

     1  // Copyright 2022 The Swarm Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package api
     6  
     7  import (
     8  	"net/http"
     9  
    10  	"github.com/ethersphere/bee/v2"
    11  	"github.com/ethersphere/bee/v2/pkg/jsonhttp"
    12  )
    13  
    14  type healthStatusResponse struct {
    15  	Status     string `json:"status"`
    16  	Version    string `json:"version"`
    17  	APIVersion string `json:"apiVersion"`
    18  }
    19  
    20  func (s *Service) healthHandler(w http.ResponseWriter, _ *http.Request) {
    21  	status := s.probe.Healthy()
    22  	jsonhttp.OK(w, healthStatusResponse{
    23  		Status:     status.String(),
    24  		Version:    bee.Version,
    25  		APIVersion: Version,
    26  	})
    27  }