summaryrefslogtreecommitdiff
path: root/src/backend/taler-merchant-httpd_helper.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/taler-merchant-httpd_helper.c')
-rw-r--r--src/backend/taler-merchant-httpd_helper.c134
1 files changed, 115 insertions, 19 deletions
diff --git a/src/backend/taler-merchant-httpd_helper.c b/src/backend/taler-merchant-httpd_helper.c
index 0e026a87..9e7a1883 100644
--- a/src/backend/taler-merchant-httpd_helper.c
+++ b/src/backend/taler-merchant-httpd_helper.c
@@ -314,7 +314,6 @@ TMH_products_array_valid (const json_t *products)
{
const char *product_id = NULL;
const char *description;
- json_t *description_i18n = NULL;
uint64_t quantity = 0;
const char *unit = NULL;
struct TALER_Amount price = { .value = 0 };
@@ -326,12 +325,8 @@ TMH_products_array_valid (const json_t *products)
GNUNET_JSON_spec_string ("product_id",
&product_id),
NULL),
- GNUNET_JSON_spec_string ("description",
- &description),
- GNUNET_JSON_spec_mark_optional (
- GNUNET_JSON_spec_json ("description_i18n",
- &description_i18n),
- NULL),
+ TALER_JSON_spec_i18n_str ("description",
+ &description),
GNUNET_JSON_spec_mark_optional (
GNUNET_JSON_spec_uint64 ("quantity",
&quantity),
@@ -386,12 +381,6 @@ TMH_products_array_valid (const json_t *products)
GNUNET_break_op (0);
valid = false;
}
- if ( (NULL != description_i18n) &&
- (! TALER_JSON_check_i18n (description_i18n)) )
- {
- GNUNET_break_op (0);
- valid = false;
- }
GNUNET_JSON_parse_free (spec);
if (! valid)
break;
@@ -598,12 +587,6 @@ TMH_check_auth_config (struct MHD_Connection *connection,
}
-/**
- * Generate binary UUID from client-provided UUID-string.
- *
- * @param uuids string intpu
- * @param[out] uuid set to binary UUID
- */
void
TMH_uuid_from_string (const char *uuids,
struct GNUNET_Uuid *uuid)
@@ -855,3 +838,116 @@ TMH_exchange_accounts_by_method (
}
return emc.accounts;
}
+
+
+enum GNUNET_GenericReturnValue
+TMH_base_url_by_connection (struct MHD_Connection *connection,
+ const char *instance,
+ struct GNUNET_Buffer *buf)
+{
+ const char *host;
+ const char *forwarded_host;
+ const char *uri_path;
+
+ memset (buf,
+ 0,
+ sizeof (*buf));
+ if (GNUNET_YES == TALER_mhd_is_https (connection))
+ GNUNET_buffer_write_str (buf, "https://");
+ else
+ GNUNET_buffer_write_str (buf, "http://");
+ host = MHD_lookup_connection_value (connection,
+ MHD_HEADER_KIND,
+ MHD_HTTP_HEADER_HOST);
+ forwarded_host = MHD_lookup_connection_value (connection,
+ MHD_HEADER_KIND,
+ "X-Forwarded-Host");
+ if (NULL != forwarded_host)
+ {
+ GNUNET_buffer_write_str (buf,
+ forwarded_host);
+ }
+ else
+ {
+ if (NULL == host)
+ {
+ GNUNET_buffer_clear (buf);
+ GNUNET_break (0);
+ return GNUNET_SYSERR;
+ }
+ GNUNET_buffer_write_str (buf,
+ host);
+ }
+ uri_path = MHD_lookup_connection_value (connection,
+ MHD_HEADER_KIND,
+ "X-Forwarded-Prefix");
+ if (NULL != uri_path)
+ GNUNET_buffer_write_path (buf,
+ uri_path);
+ if (0 != strcmp (instance,
+ "default"))
+ {
+ GNUNET_buffer_write_path (buf,
+ "/instances/");
+ GNUNET_buffer_write_str (buf,
+ instance);
+ }
+ return GNUNET_OK;
+}
+
+
+enum GNUNET_GenericReturnValue
+TMH_taler_uri_by_connection (struct MHD_Connection *connection,
+ const char *method,
+ const char *instance,
+ struct GNUNET_Buffer *buf)
+{
+ const char *host;
+ const char *forwarded_host;
+ const char *uri_path;
+
+ memset (buf,
+ 0,
+ sizeof (*buf));
+ host = MHD_lookup_connection_value (connection,
+ MHD_HEADER_KIND,
+ "Host");
+ forwarded_host = MHD_lookup_connection_value (connection,
+ MHD_HEADER_KIND,
+ "X-Forwarded-Host");
+ uri_path = MHD_lookup_connection_value (connection,
+ MHD_HEADER_KIND,
+ "X-Forwarded-Prefix");
+ if (NULL != forwarded_host)
+ host = forwarded_host;
+ if (NULL == host)
+ {
+ GNUNET_break (0);
+ return GNUNET_SYSERR;
+ }
+ GNUNET_buffer_write_str (buf,
+ "taler");
+ if (GNUNET_NO == TALER_mhd_is_https (connection))
+ GNUNET_buffer_write_str (buf,
+ "+http");
+ GNUNET_buffer_write_str (buf,
+ "://");
+ GNUNET_buffer_write_str (buf,
+ method);
+ GNUNET_buffer_write_str (buf,
+ "/");
+ GNUNET_buffer_write_str (buf,
+ host);
+ if (NULL != uri_path)
+ GNUNET_buffer_write_path (buf,
+ uri_path);
+ if (0 != strcmp ("default",
+ instance))
+ {
+ GNUNET_buffer_write_path (buf,
+ "instances");
+ GNUNET_buffer_write_path (buf,
+ instance);
+ }
+ return GNUNET_OK;
+}