2024-10-20 03:39:07 +03:00
|
|
|
package api
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"net/http"
|
2024-10-20 20:38:08 +03:00
|
|
|
"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)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-10-20 20:38:08 +03:00
|
|
|
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
|
|
|
}
|