Mercurial > sci
diff scid/crud.h @ 33:1d0ddf9e6efd
misc: general documentation
author | David Demelier <markand@malikania.fr> |
---|---|
date | Thu, 04 Aug 2022 16:47:10 +0200 |
parents | 081e1c258e64 |
children | 71cd8447e3a4 |
line wrap: on
line diff
--- a/scid/crud.h Thu Aug 04 14:59:33 2022 +0200 +++ b/scid/crud.h Thu Aug 04 16:47:10 2022 +0200 @@ -19,14 +19,47 @@ #ifndef SCID_CRUD_H #define SCID_CRUD_H +/** + * \file crud.h + * \brief Convenient helpers for API pages. + * + * This module uses the database to fetch or insert data and finally show the + * result as HTTP response. + * + * This module logs message with tag `crud`. + */ + #include <jansson.h> struct kreq; +/** + * Decode the JSON input and insert them using the appropriate database + * function provided. + * + * \pre r != NULL + * \pre saver != NULL + * \pre topic != NULL + * \param r the request + * \param saver the function to save in database + * \param topic the log topic for diagnostic + */ void -crud_insert(struct kreq *, int (*)(json_t *), const char *); +crud_insert(struct kreq *r, int (*saver)(json_t *), const char *topic); +/** + * Convert the JSON provided value. + * + * For convenience, if the document is NULL (which happen if the database + * access failed) it will send a HTTP 500 error. Otherwise it is listed and + * free'd. + * + * \pre r != NULL + * \param r the request + * \param doc the document to send (maybe NULL) + * \warning The document will be destroyed using json_decref. + */ void -crud_list(struct kreq *, json_t *); +crud_list(struct kreq *r, json_t *doc); #endif /* !SCID_CRUD_H */