diff options
author | Özgür Kesim <oec-taler@kesim.org> | 2023-05-12 13:40:22 +0200 |
---|---|---|
committer | Özgür Kesim <oec-taler@kesim.org> | 2023-05-12 13:40:22 +0200 |
commit | 4833234df63d7da774299b336adb925e700bd4b4 (patch) | |
tree | abb478b860c2d3f292ded9364300ce73b1d60d11 /src/templating/templating_api.c | |
parent | 9130cda9e775131d3ced613b7f238a4c9e43ad5a (diff) | |
parent | ff1a28319fe31741958a0b1cfa761fd44878db45 (diff) |
Merge branch 'master' into age-withdraw
Diffstat (limited to 'src/templating/templating_api.c')
-rw-r--r-- | src/templating/templating_api.c | 60 |
1 files changed, 52 insertions, 8 deletions
diff --git a/src/templating/templating_api.c b/src/templating/templating_api.c index 324e199e..9261bde7 100644 --- a/src/templating/templating_api.c +++ b/src/templating/templating_api.c @@ -180,10 +180,12 @@ TALER_TEMPLATING_fill (const char *tmpl, int eno; if (0 != - (eno = mustach_jansson (tmpl, - (json_t *) root, - (char **) result, - result_size))) + (eno = mustach_jansson_mem (tmpl, + 0, /* length of tmpl */ + (json_t *) root, + Mustach_With_NoExtensions, + (char **) result, + result_size))) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "mustach failed on template with error %d\n", @@ -237,10 +239,12 @@ TALER_TEMPLATING_build (struct MHD_Connection *connection, GNUNET_free (static_url); } if (0 != - (eno = mustach_jansson (tmpl, - (json_t *) root, - &body, - &body_size))) + (eno = mustach_jansson_mem (tmpl, + 0, + (json_t *) root, + Mustach_With_NoExtensions, + &body, + &body_size))) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "mustach failed on template `%s' with error %d\n", @@ -428,6 +432,46 @@ load_template (void *cls, } +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) +{ + json_t *data; + enum GNUNET_GenericReturnValue ret; + + data = GNUNET_JSON_PACK ( + GNUNET_JSON_pack_uint64 ("ec", + ec), + GNUNET_JSON_pack_string ("hint", + TALER_ErrorCode_get_hint (ec)), + GNUNET_JSON_pack_allow_null ( + GNUNET_JSON_pack_string ("detail", + detail)) + ); + ret = TALER_TEMPLATING_reply (connection, + http_status, + template_basename, + NULL, + NULL, + data); + json_decref (data); + switch (ret) + { + case GNUNET_OK: + return MHD_YES; + case GNUNET_NO: + return MHD_YES; + case GNUNET_SYSERR: + return MHD_NO; + } + GNUNET_assert (0); + return MHD_NO; +} + + enum GNUNET_GenericReturnValue TALER_TEMPLATING_init (const char *subsystem) { |