Library/routes/api/v1/items_list.go

23 lines
452 B
Go
Raw Normal View History

package v1
import (
2018-03-05 11:53:12 +00:00
"git.kolaente.de/konrad/Library/models"
"github.com/labstack/echo"
"net/http"
)
// ItemsList is the handler to list Items, optionally filtered
func ItemsList(c echo.Context) error {
// Prepare the searchterm
search := c.QueryParam("s")
list, err := models.ListItems(search)
if err != nil {
2018-01-15 12:20:58 +00:00
return c.JSON(http.StatusInternalServerError, models.Message{"Error getting items."})
}
return c.JSON(http.StatusOK, list)
}