grim/devweb
Clone
Summary
Browse
Changes
Graph
Remove api_key_access_key from the books_version table as it really isn't necessary
draft
default
tip
2021-01-25, Gary Kramlich
533ca8fcc53b
Remove api_key_access_key from the books_version table as it really isn't necessary
package
v1
import
(
"net/http"
"github.com/gin-gonic/gin"
log
"github.com/sirupsen/logrus"
"keep.imfreedom.org/grim/devweb/db"
)
func
getBooks
(
c
*
gin
.
Context
)
{
books
,
err
:=
db
.
ListBooks
()
if
err
!=
nil
{
log
.
Errorf
(
"failed to get books: %v"
,
err
)
c
.
AbortWithStatus
(
http
.
StatusInternalServerError
)
}
else
{
d
:=
struct
{
Books
[]
db
.
Book
`json:"books"`
}{
books
,
}
c
.
JSON
(
http
.
StatusOK
,
d
)
}
}
func
createBook
(
c
*
gin
.
Context
)
{
var
book
db
.
Book
c
.
Bind
(
&
book
)
if
err
:=
book
.
Create
();
err
!=
nil
{
c
.
AbortWithStatus
(
http
.
StatusBadRequest
)
return
}
c
.
Redirect
(
http
.
StatusFound
,
book
.
ID
)
}