29 lines
516 B
Go
29 lines
516 B
Go
|
package apiv2
|
||
|
|
||
|
import (
|
||
|
"net/http"
|
||
|
|
||
|
"github.com/labstack/echo/v4"
|
||
|
)
|
||
|
|
||
|
func (a *API) getMessagesHandler(c echo.Context) error {
|
||
|
q := new(getMessagesRequest)
|
||
|
if err := c.Bind(q); err != nil {
|
||
|
return err
|
||
|
}
|
||
|
|
||
|
msgs, err := a.idec.GetMessagesByEcho(q.Echo, q.Message, q.Offset, q.Limit)
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
|
||
|
return c.JSON(http.StatusOK, msgs)
|
||
|
}
|
||
|
|
||
|
type getMessagesRequest struct {
|
||
|
Echo string `query:"e"`
|
||
|
Message string `query:"m"`
|
||
|
Offset int `query:"offset"`
|
||
|
Limit int `query:"limit"`
|
||
|
}
|