29 lines
592 B
Go
29 lines
592 B
Go
package api
|
|
|
|
import (
|
|
"fmt"
|
|
"net/http"
|
|
"strings"
|
|
)
|
|
|
|
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"))
|
|
}
|