summaryrefslogtreecommitdiff
path: root/pkg/api/list.go
blob: 80a34ea0799fe4c2ed72899110b4818844834767 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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"))
}