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

     1  // Copyright 2023 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/pkg/jsonhttp"
    11  	"github.com/ethersphere/bee/v2/pkg/tracing"
    12  )
    13  
    14  func (s *Service) debugStorage(w http.ResponseWriter, r *http.Request) {
    15  	logger := tracing.NewLoggerWithTraceID(r.Context(), s.logger.WithName("debug_storage").Build())
    16  
    17  	info, err := s.storer.DebugInfo(r.Context())
    18  	if err != nil {
    19  		logger.Debug("get debug storage info failed", "error", err)
    20  		logger.Error(nil, "get debug storage info failed")
    21  		jsonhttp.InternalServerError(w, "debug storage info not available")
    22  		return
    23  	}
    24  
    25  	jsonhttp.OK(w, info)
    26  }