Skip to content

Commit 3fd41b7

Browse files
committed
Make MGOS_RPC_HTTP_URI_PREFIX public
1 parent ba3bd49 commit 3fd41b7

File tree

2 files changed

+11
-13
lines changed

2 files changed

+11
-13
lines changed

include/mgos_rpc.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@
1515
* limitations under the License.
1616
*/
1717

18-
#ifndef CS_FW_SRC_MGOS_MG_RPC_H_
19-
#define CS_FW_SRC_MGOS_MG_RPC_H_
18+
#pragma once
2019

2120
#include "mg_rpc.h"
2221

@@ -31,6 +30,8 @@
3130
extern "C" {
3231
#endif /* __cplusplus */
3332

33+
#define MGOS_RPC_HTTP_URI_PREFIX "/rpc"
34+
3435
bool mgos_rpc_common_init(void);
3536
struct mg_rpc *mgos_rpc_get_global(void);
3637
struct mg_rpc_cfg *mgos_rpc_cfg_from_sys(const struct mgos_config *scfg);
@@ -70,6 +71,4 @@ enum mgos_rpc_event {
7071

7172
#ifdef __cplusplus
7273
}
73-
#endif /* __cplusplus */
74-
75-
#endif /* CS_FW_SRC_MGOS_MG_RPC_H_ */
74+
#endif

src/mgos_rpc.c

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,6 @@
5050
#include "mgos_pppos.h"
5151
#endif
5252

53-
#define HTTP_URI_PREFIX "/rpc"
54-
5553
static struct mg_rpc *s_global_mg_rpc;
5654

5755
extern const char *mg_build_id;
@@ -84,7 +82,7 @@ static void mgos_rpc_http_handler(struct mg_connection *nc, int ev,
8482
struct mg_rpc_channel *ch =
8583
mg_rpc_channel_http(nc, auth_domain, auth_file, &is_new);
8684
struct http_message *hm = (struct http_message *) ev_data;
87-
size_t prefix_len = sizeof(HTTP_URI_PREFIX) - 1;
85+
size_t prefix_len = sizeof(MGOS_RPC_HTTP_URI_PREFIX) - 1;
8886
if (ch == NULL) {
8987
mg_http_send_error(nc, 500, "Failed to create channel");
9088
return;
@@ -549,11 +547,12 @@ bool mgos_rpc_common_init(void) {
549547

550548
#if defined(MGOS_HAVE_HTTP_SERVER) && MGOS_ENABLE_RPC_CHANNEL_HTTP
551549
if (mgos_sys_config_get_rpc_http_enable()) {
552-
struct mg_http_endpoint_opts opts;
553-
memset(&opts, 0, sizeof(opts));
554-
555-
mgos_register_http_endpoint_opt(HTTP_URI_PREFIX, mgos_rpc_http_handler,
556-
opts);
550+
struct mg_http_endpoint_opts opts = {
551+
.auth_domain = NULL,
552+
.auth_file = NULL,
553+
};
554+
mgos_register_http_endpoint_opt(MGOS_RPC_HTTP_URI_PREFIX,
555+
mgos_rpc_http_handler, opts);
557556
}
558557
#endif
559558

0 commit comments

Comments
 (0)