diff options
Diffstat (limited to 'src/include/taler_templating_lib.h')
-rw-r--r-- | src/include/taler_templating_lib.h | 41 |
1 files changed, 39 insertions, 2 deletions
diff --git a/src/include/taler_templating_lib.h b/src/include/taler_templating_lib.h index 9cce84f5a..6af6db715 100644 --- a/src/include/taler_templating_lib.h +++ b/src/include/taler_templating_lib.h @@ -22,6 +22,23 @@ #define TALER_TEMPLATING_LIB_H #include <microhttpd.h> +#include "taler_mhd_lib.h" + +/** + * Fill in Mustach template @a tmpl using the data from @a root + * and return the result in @a result. + * + * @param tmpl 0-terminated string with Mustach template + * @param root JSON data to fill into the template + * @param[out] result where to write the result + * @param[out] result_size where to write the length of the result + * @return 0 on success, otherwise Mustach-specific error code + */ +int +TALER_TEMPLATING_fill (const char *tmpl, + const json_t *root, + void **result, + size_t *result_size); /** @@ -48,7 +65,7 @@ TALER_TEMPLATING_build (struct MHD_Connection *connection, const char *template, const char *instance_id, const char *taler_uri, - json_t *root, + const json_t *root, struct MHD_Response **reply); @@ -72,7 +89,27 @@ TALER_TEMPLATING_reply (struct MHD_Connection *connection, const char *template, const char *instance_id, const char *taler_uri, - json_t *root); + const json_t *root); + + +/** + * Load a @a template and substitute an error message based on @a ec and @a + * detail, returning the result to the @a connection with the given @a + * http_status code. + * + * @param connection the connection we act upon + * @param template_basename basename of the template to load + * @param http_status code to use on success + * @param ec error code to return + * @param detail optional text to add to the template + * @return #MHD_YES on success, #MHD_NO to just close the connection + */ +MHD_RESULT +TALER_TEMPLATING_reply_error (struct MHD_Connection *connection, + const char *template_basename, + unsigned int http_status, + enum TALER_ErrorCode ec, + const char *detail); /** * Preload templates. |