github.com/ethersphere/bee/v2@v2.2.0/pkg/api/node.go (about) 1 // Copyright 2021 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 ) 12 13 type BeeNodeMode uint 14 15 const ( 16 UnknownMode BeeNodeMode = iota 17 LightMode 18 FullMode 19 DevMode 20 UltraLightMode 21 ) 22 23 type nodeResponse struct { 24 BeeMode string `json:"beeMode"` 25 ChequebookEnabled bool `json:"chequebookEnabled"` 26 SwapEnabled bool `json:"swapEnabled"` 27 } 28 29 func (b BeeNodeMode) String() string { 30 switch b { 31 case LightMode: 32 return "light" 33 case FullMode: 34 return "full" 35 case DevMode: 36 return "dev" 37 case UltraLightMode: 38 return "ultra-light" 39 } 40 return "unknown" 41 } 42 43 // nodeGetHandler gives back information about the Bee node configuration. 44 func (s *Service) nodeGetHandler(w http.ResponseWriter, _ *http.Request) { 45 jsonhttp.OK(w, nodeResponse{ 46 BeeMode: s.beeMode.String(), 47 ChequebookEnabled: s.chequebookEnabled, 48 SwapEnabled: s.swapEnabled, 49 }) 50 }