36 lines
634 B
Go
36 lines
634 B
Go
package apiv2
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/labstack/echo/v4"
|
|
)
|
|
|
|
func (a *API) getListHandler(c echo.Context) error {
|
|
echos, err := a.idec.GetEchos()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
return c.JSON(http.StatusOK, echos)
|
|
}
|
|
|
|
func (a *API) getEchoHandler(c echo.Context) error {
|
|
q := new(getEchosRequest)
|
|
if err := c.Bind(q); err != nil {
|
|
return err
|
|
}
|
|
|
|
echos, err := a.idec.GetEchosByIDs(q.EchoIDs, q.Offset, q.Limit)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
return c.JSON(http.StatusOK, echos)
|
|
}
|
|
|
|
type getEchosRequest struct {
|
|
EchoIDs []string `query:"e"`
|
|
Offset int `query:"offset"`
|
|
Limit int `query:"limit"`
|
|
}
|