Skip to content
This repository was archived by the owner on Dec 26, 2022. It is now read-only.

Commit 95a1723

Browse files
committed
fix(router): Sync url path to MAM implementation
With URL path `mam/send`, a user can send MAM message With URL path `mam/recv`, a user can receive MAM message. API `recv_mam_message()` has been changed to POST method from this PR, so the old GET method matcher has been removed here.
1 parent 9dc590f commit 95a1723

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed

connectivity/http/http.c

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -142,14 +142,9 @@ static inline int process_send_transfer_request(ta_http_t *const http, iota_clie
142142
}
143143

144144
static inline int process_recv_mam_msg_request(ta_http_t *const http, iota_client_service_t *const iota_service,
145-
char const *const url, char **const out) {
145+
char const *const payload, char **const out) {
146146
status_t ret;
147-
char *bundle = NULL;
148-
ret = ta_get_url_parameter(url, 1, &bundle);
149-
if (ret == SC_OK) {
150-
ret = api_recv_mam_message(&http->core->iota_conf, iota_service, bundle, out);
151-
}
152-
free(bundle);
147+
ret = api_recv_mam_message(&http->core->iota_conf, iota_service, payload, out);
153148
return set_response_content(ret, out);
154149
}
155150

@@ -256,14 +251,16 @@ static int ta_http_process_request(ta_http_t *const http, iota_client_service_t
256251
return process_options_request(out);
257252
}
258253

259-
if (api_path_matcher(url, "/mam/[A-Z9]{81}[/]?") == SC_OK) {
260-
return process_recv_mam_msg_request(http, iota_service, url, out);
261-
} else if (api_path_matcher(url, "/mam[/]?") == SC_OK) {
262-
if (payload != NULL) {
263-
return process_send_mam_msg_request(http, iota_service, payload, out);
254+
if (api_path_matcher(url, "/mam/(recv|send)[/]?") == SC_OK) {
255+
if (payload == NULL) {
256+
return process_method_not_allowed_request(out);
264257
}
265-
return process_method_not_allowed_request(out);
266258

259+
if (api_path_matcher(url, ".*/recv.*") == SC_OK) {
260+
return process_recv_mam_msg_request(http, iota_service, payload, out);
261+
} else {
262+
return process_send_mam_msg_request(http, iota_service, payload, out);
263+
}
267264
} else if (api_path_matcher(url, "/transaction/[A-Z9]{81}[/]?") == SC_OK) {
268265
return process_find_txn_obj_single_request(iota_service, url, out);
269266
} else if (api_path_matcher(url, "/transaction/object[/]?") == SC_OK) {

0 commit comments

Comments
 (0)