Fix bug book 0
This commit is contained in:
parent
a28be1c39f
commit
e06ae559d6
1
db.c
1
db.c
@ -79,6 +79,7 @@ db_book_load(struct kreq *r, int64_t id)
|
||||
{
|
||||
struct ksqlstmt *stmt;
|
||||
Book *book;
|
||||
|
||||
ksql_stmt_alloc(r->arg, &stmt,
|
||||
stmts[STMT_BOOK],
|
||||
STMT_BOOK);
|
||||
|
4
main.c
4
main.c
@ -116,12 +116,12 @@ sendbooks(struct kreq *r)
|
||||
id = r->fieldmap[KEY_ID]->parsed.i;
|
||||
if (r->path[0] != '\0')
|
||||
id = strtonum(r->path, INT64_MIN, INT64_MAX, &errid);
|
||||
if (id > 0) {
|
||||
if (id >= 0) {
|
||||
b = db_book_load(r, id);
|
||||
}
|
||||
http_open(r, (id > 0 && NULL == b) ? KHTTP_404 : KHTTP_200);
|
||||
kjson_open(&req, r);
|
||||
if (id >0 && NULL == b) {
|
||||
if (id >= 0 && NULL == b) {
|
||||
puterror(&req, "Unknown book");
|
||||
} else if (NULL != b) {
|
||||
putbook(&req, b);
|
||||
|
Loading…
Reference in New Issue
Block a user