2017-10-09 12:29:21 +00:00
|
|
|
package v1
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/labstack/echo"
|
|
|
|
"net/http"
|
2017-10-09 16:20:16 +00:00
|
|
|
|
2017-12-01 10:33:40 +00:00
|
|
|
"fmt"
|
2017-12-01 11:38:36 +00:00
|
|
|
"git.mowie.cc/konrad/Library/models"
|
2017-10-09 12:29:21 +00:00
|
|
|
)
|
|
|
|
|
2017-11-08 09:55:17 +00:00
|
|
|
// BookList is the handler to list books
|
2017-10-10 15:01:33 +00:00
|
|
|
func BookList(c echo.Context) error {
|
2017-10-09 16:20:16 +00:00
|
|
|
|
2017-11-29 14:22:25 +00:00
|
|
|
// Prepare the searchterm
|
|
|
|
search := c.QueryParam("s")
|
|
|
|
|
|
|
|
list, err := models.ListBooks(search)
|
2017-10-09 16:29:09 +00:00
|
|
|
|
2017-11-07 15:35:10 +00:00
|
|
|
if err != nil {
|
2017-12-01 10:33:40 +00:00
|
|
|
fmt.Println(err)
|
2018-01-15 12:20:58 +00:00
|
|
|
return c.JSON(http.StatusInternalServerError, models.Message{"Error getting books."})
|
2017-10-09 16:29:09 +00:00
|
|
|
}
|
2017-10-09 16:20:16 +00:00
|
|
|
|
|
|
|
return c.JSON(http.StatusOK, list)
|
2017-11-07 15:35:10 +00:00
|
|
|
}
|