summaryrefslogtreecommitdiff
path: root/pkg/apiv1/list.go
blob: 1e5dafc7a5bc672b5ed67c9445d140fd67984b78 (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
30
31
32
package apiv1

import (
	"fmt"
	"strings"

	"github.com/labstack/echo/v4"
)

func (a *API) getListHandler(c echo.Context) error {
	echos, err := a.idec.GetEchos()
	if err != nil {
		return echo.ErrInternalServerError
	}

	for _, e := range echos {
		fmt.Fprintf(c.Response(), "%s:%d:%s\n", e.Name, e.Count, e.Description)
	}

	return nil
}

func (a *API) getBlacklistHandler(c echo.Context) error {
	list, err := a.idec.GetBlacklist()
	if err != nil {
		return echo.ErrInternalServerError
	}

	fmt.Fprint(c.Response(), strings.Join(list, "\n"))

	return nil
}