package peers import ( "encoding/json" "net/http" ) type PeerHandler struct { peerService *PeerService } func NewPeerHandler(peerService *PeerService) *PeerHandler { return &PeerHandler{ peerService: peerService, } } func (h *PeerHandler) ListTrustedPeers(w http.ResponseWriter, r *http.Request) { if r.Method != http.MethodGet { http.Error(w, "Method not allowed", http.StatusMethodNotAllowed) return } peers, err := h.peerService.ListTrustedPeers() if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return } w.Header().Set("Content-Type", "application/json") json.NewEncoder(w).Encode(peers) }