diff options
Diffstat (limited to 'pkg/api/echo.go')
-rw-r--r-- | pkg/api/echo.go | 57 |
1 files changed, 0 insertions, 57 deletions
diff --git a/pkg/api/echo.go b/pkg/api/echo.go deleted file mode 100644 index 8f7a852..0000000 --- a/pkg/api/echo.go +++ /dev/null @@ -1,57 +0,0 @@ -package api - -import ( - "fmt" - "net/http" - "strings" -) - -func (a *API) getEchoHandler(w http.ResponseWriter, r *http.Request) { - echoID := r.PathValue("id") - echos, err := a.idec.GetEchosByIDs([]string{echoID}, 0, 0) - if err != nil { - http.Error(w, err.Error(), http.StatusBadRequest) - return - } - - if len(echos) == 0 { - return - } - - fmt.Fprint(w, strings.Join(echos[echoID].Messages, "\n")) -} - -func (a *API) getEchosHandler(w http.ResponseWriter, r *http.Request) { - ids := strings.Split(r.PathValue("ids"), "/") - last := ids[len(ids)-1] - offset, limit := 0, 0 - if _, err := fmt.Sscanf(last, "%d:%d", &offset, &limit); err == nil { - ids = ids[:len(ids)-1] - } - echos, err := a.idec.GetEchosByIDs(ids, offset, limit) - if err != nil { - http.Error(w, err.Error(), http.StatusBadRequest) - return - } - - for _, echoID := range ids { - e := echos[echoID] - fmt.Fprintln(w, e.Name) - if len(e.Messages) > 0 { - fmt.Fprintln(w, strings.Join(e.Messages, "\n")) - } - } -} - -func (a *API) getEchosInfo(w http.ResponseWriter, r *http.Request) { - ids := strings.Split(r.PathValue("ids"), "/") - echos, err := a.idec.GetEchosByIDs(ids, 0, 0) - if err != nil { - http.Error(w, err.Error(), http.StatusBadRequest) - return - } - - for _, e := range echos { - fmt.Fprintf(w, "%s:%d\n", e.Name, e.Count) - } -} |