idecnode/pkg/api/list.go

30 lines
592 B
Go
Raw Normal View History

2024-10-20 03:39:07 +03:00
package api
import (
"fmt"
"net/http"
"strings"
2024-10-20 03:39:07 +03:00
)
func (a *API) getListHandler(w http.ResponseWriter, r *http.Request) {
echos, err := a.idec.GetEchos()
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
for _, e := range echos {
fmt.Fprintf(w, "%s:%d:%s\n", e.Name, e.Count, e.Description)
}
}
func (a *API) getBlacklistHandler(w http.ResponseWriter, r *http.Request) {
list, err := a.idec.GetBlacklist()
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
fmt.Fprint(w, strings.Join(list, "\n"))
2024-10-20 03:39:07 +03:00
}