[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-merchant] branch master updated: implementing #5288
From: |
gnunet |
Subject: |
[taler-merchant] branch master updated: implementing #5288 |
Date: |
Tue, 07 Apr 2020 14:35:58 +0200 |
This is an automated email from the git hooks/post-receive script.
grothoff pushed a commit to branch master
in repository merchant.
The following commit(s) were added to refs/heads/master by this push:
new a6a0562 implementing #5288
a6a0562 is described below
commit a6a0562bcef27d6f213646c5bbf6129fcfe65377
Author: Christian Grothoff <address@hidden>
AuthorDate: Tue Apr 7 14:35:56 2020 +0200
implementing #5288
---
src/backend/taler-merchant-httpd.h | 9 ++++-
src/backend/taler-merchant-httpd_config.c | 60 +++++++++++++++++++++++++++----
src/include/taler_merchant_service.h | 2 +-
src/lib/merchant_api_config.c | 13 +++++--
4 files changed, 74 insertions(+), 10 deletions(-)
diff --git a/src/backend/taler-merchant-httpd.h
b/src/backend/taler-merchant-httpd.h
index 4695edd..1e3aac5 100644
--- a/src/backend/taler-merchant-httpd.h
+++ b/src/backend/taler-merchant-httpd.h
@@ -101,7 +101,7 @@ struct WireMethod
/**
- * Information that defines a merchant "instance". Tha4673t way, a single
+ * Information that defines a merchant "instance". That way, a single
* backend can account for several merchants, as used to do in donation
* shops
*/
@@ -357,6 +357,13 @@ extern struct TALER_MerchantPrivateKeyP privkey;
*/
extern struct TALER_MerchantPublicKeyP pubkey;
+/**
+ * Hashmap pointing at merchant instances by 'id'. An 'id' is
+ * just a string that identifies a merchant instance. When a frontend
+ * needs to specify an instance to the backend, it does so by 'id'
+ */
+extern struct GNUNET_CONTAINER_MultiHashMap *by_id_map;
+
/**
* Handle to the database backend.
*/
diff --git a/src/backend/taler-merchant-httpd_config.c
b/src/backend/taler-merchant-httpd_config.c
index 10a9160..8282cff 100644
--- a/src/backend/taler-merchant-httpd_config.c
+++ b/src/backend/taler-merchant-httpd_config.c
@@ -42,11 +42,44 @@
*
* When changing this version, you likely want to also update
* #MERCHANT_PROTOCOL_CURRENT and #MERCHANT_PROTOCOL_AGE in
- * TBD.c! // FIXME: update comment once libtalermerchant looks at version!
+ * merchant_api_config.c!
*/
#define MERCHANT_PROTOCOL_VERSION "0:0:0"
+static int
+add_instance (void *cls,
+ const struct GNUNET_HashCode *key,
+ void *value)
+{
+ json_t *ja = cls;
+ struct MerchantInstance *mi = value;
+ char *url;
+
+ GNUNET_asprintf (&url,
+ "/%s/",
+ mi->id);
+ GNUNET_assert (0 ==
+ json_array_append_new (
+ ja,
+ json_pack (
+ (NULL != mi->tip_exchange)
+ ? "{s:s, s:s, s:o, s:s}"
+ : "{s:s, s:s, s:o}",
+ "name",
+ mi->name,
+ "backend_base_url",
+ url,
+ "merchant_pub",
+ GNUNET_JSON_from_data_auto (&mi->pubkey),
+ /* optional: */
+ "tipping_exchange_baseurl",
+ mi->tip_exchange)));
+ GNUNET_free (url);
+ return GNUNET_OK;
+}
+
+
/**
* Handle a "/config" request.
*
@@ -66,16 +99,31 @@ MH_handler_config (struct TMH_RequestHandler *rh,
size_t *upload_data_size,
struct MerchantInstance *mi)
{
+ static struct MHD_Response *response;
+
(void) rh;
(void) connection_cls;
(void) upload_data;
(void) upload_data_size;
(void) mi;
- return TALER_MHD_reply_json_pack (connection,
- MHD_HTTP_OK,
- "{s:s, s:s}",
- "currency", TMH_currency,
- "version", MERCHANT_PROTOCOL_VERSION);
+ if (NULL == response)
+ {
+ json_t *ia;
+
+ ia = json_array ();
+ GNUNET_assert (NULL != ia);
+ GNUNET_CONTAINER_multihashmap_iterate (by_id_map,
+ &add_instance,
+ ia);
+ response = TALER_MHD_make_json_pack ("{s:s, s:s, s:o}",
+ "currency", TMH_currency,
+ "version", MERCHANT_PROTOCOL_VERSION,
+ "instances", ia);
+
+ }
+ return MHD_queue_response (connection,
+ MHD_HTTP_OK,
+ response);
}
diff --git a/src/include/taler_merchant_service.h
b/src/include/taler_merchant_service.h
index c99f18b..ac7e427 100644
--- a/src/include/taler_merchant_service.h
+++ b/src/include/taler_merchant_service.h
@@ -184,7 +184,7 @@ struct TALER_MERCHANT_InstanceInformation
/**
* URL of this instance. The URL can be relative to the current domain
* (i.e. "/PizzaShop/") or include a schema and fully qualified domain name
- * (i.e. "https://backend.example.com/"). The latter can be used to redirect
+ * (i.e. "https://backend.example.com/PS/"). The latter can be used to
redirect
* clients to a different server in case the deployment location changes.
*/
const char *instance_baseurl;
diff --git a/src/lib/merchant_api_config.c b/src/lib/merchant_api_config.c
index 16c2014..1d958a8 100644
--- a/src/lib/merchant_api_config.c
+++ b/src/lib/merchant_api_config.c
@@ -109,10 +109,9 @@ parse_instances (const json_t *ia,
&ii->instance_baseurl),
GNUNET_JSON_spec_string ("name",
&ii->name),
- GNUNET_JSON_spec_string ("tipping_exchange_baseurl",
- &ii->tipping_exchange_baseurl),
GNUNET_JSON_spec_end ()
};
+ json_t *teb;
if (GNUNET_OK !=
GNUNET_JSON_parse (value,
@@ -121,7 +120,17 @@ parse_instances (const json_t *ia,
{
GNUNET_break_op (0);
ret = GNUNET_SYSERR;
+ continue;
}
+ teb = json_object_get (value,
+ "tipping_exchange_baseurl");
+ if (! json_is_string (teb))
+ {
+ GNUNET_break_op (0);
+ ret = GNUNET_SYSERR;
+ continue;
+ }
+ ii->tipping_exchange_baseurl = json_string_value (teb);
}
return ret;
}
--
To stop receiving notification emails like this one, please contact
address@hidden.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [taler-merchant] branch master updated: implementing #5288,
gnunet <=