gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-merchant] 45/277: baseURL construction helper function'


From: gnunet
Subject: [taler-merchant] 45/277: baseURL construction helper function'
Date: Sun, 05 Jul 2020 20:49:18 +0200

This is an automated email from the git hooks/post-receive script.

grothoff pushed a commit to branch master
in repository merchant.

commit 874f09525fee53e8a69f040cd3cf9b4f369fdee5
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Fri Apr 24 19:40:48 2020 +0200

    baseURL construction helper function'
---
 src/include/taler_merchant_service.h | 15 +++++++++++++++
 src/lib/merchant_api_common.c        | 34 ++++++++++++++++++++++++++++++++++
 2 files changed, 49 insertions(+)

diff --git a/src/include/taler_merchant_service.h 
b/src/include/taler_merchant_service.h
index 435f65d..98acae6 100644
--- a/src/include/taler_merchant_service.h
+++ b/src/include/taler_merchant_service.h
@@ -121,6 +121,21 @@ TALER_MERCHANT_parse_error_details_ (const json_t 
*response,
                                      struct TALER_MERCHANT_HttpResponse *hr);
 
 
+/**
+ * Construct a new base URL using the existing @a base_url
+ * and the given @a instance_id.  The result WILL end with
+ * '/'.
+ *
+ * @param base_url a merchant base URL without "/instances/" in it,
+ *         must not be the empty string; MAY end with '/'.
+ * @param instance_id ID of an instance
+ * @return "${base_url}/instances/${instance_id}/"
+ */
+char *
+TALER_MERCHANT_baseurl_add_instance (const char *base_url,
+                                     const char *instance_id);
+
+
 /* ********************* /public/config ****************** */
 
 
diff --git a/src/lib/merchant_api_common.c b/src/lib/merchant_api_common.c
index cb8de65..4d69e72 100644
--- a/src/lib/merchant_api_common.c
+++ b/src/lib/merchant_api_common.c
@@ -116,3 +116,37 @@ TALER_MERCHANT_parse_error_details_ (const json_t 
*response,
     hr->exchange_hint = json_string_value (jc);
   }
 }
+
+
+/**
+ * Construct a new base URL using the existing @a base_url
+ * and the given @a instance_id.  The result WILL end with
+ * '/'.
+ *
+ * @param base_url a merchant base URL without "/instances/" in it,
+ *         must not be the empty string; MAY end with '/'.
+ * @param instance_id ID of an instance
+ * @return "${base_url}/instances/${instance_id}/"
+ */
+char *
+TALER_MERCHANT_baseurl_add_instance (const char *base_url,
+                                     const char *instance_id)
+{
+  char *ret;
+  bool end_sl;
+
+  if ('\0' == *base_url)
+  {
+    GNUNET_break (0);
+    return NULL;
+  }
+  end_sl = '/' == base_url[strlen (base_url) - 1];
+
+  GNUNET_asprintf (&ret,
+                   (end_sl)
+                   ? "%sinstances/%s/"
+                   : "%s/instances/%s/",
+                   base_url,
+                   instance_id);
+  return ret;
+}

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]