Param in path

This commit is contained in:
Meutel 2016-12-29 19:33:51 +01:00
parent a37712e0fe
commit 220ada8c7e

15
main.c
View File

@ -90,14 +90,23 @@ static void
sendbooks(struct kreq *r)
{
struct kjsonreq req;
const char *errid;
int64_t id = -1;
http_open(r, KHTTP_200);
kjson_open(&req, r);
kjson_obj_open(&req);
kjson_putstringp(&req, "data", "books");
if (NULL != r->fieldmap[KEY_ID]) {
kjson_putintp(&req, "id", r->fieldmap[KEY_ID]->parsed.i);
}
if (NULL != r->fieldmap[KEY_ID])
id = r->fieldmap[KEY_ID]->parsed.i;
if (r->path[0] != '\0')
id = strtonum(r->path, INT64_MIN, INT64_MAX, &errid);
if (id > 0)
kjson_putintp(&req, "id", id);
kjson_putstringp(&req, "_path", r->path);
kjson_putstringp(&req, "_pname", r->pname);
kjson_putstringp(&req, "_pagename", r->pagename);
kjson_obj_close(&req);
kjson_close(&req);
}