This repository was archived by the owner on Dec 26, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -79,6 +79,36 @@ int main(int, char const**) {
79
79
res << json_result;
80
80
});
81
81
82
+ mux.handle (" /mam" )
83
+ .method (served::method::OPTIONS,
84
+ [&](served::response& res, const served::request& req) {
85
+ set_method_header (res, HTTP_METHOD_OPTIONS);
86
+ })
87
+ .post ([&](served::response& res, const served::request& req) {
88
+ status_t ret = SC_OK;
89
+ char * json_result;
90
+ char * chid_result;
91
+
92
+ if (req.header (" content-type" ).find (" application/json" ) ==
93
+ std::string::npos) {
94
+ cJSON* json_obj = cJSON_CreateObject ();
95
+ cJSON_AddStringToObject (json_obj, " message" ,
96
+ " Invalid request header" );
97
+ json_result = cJSON_PrintUnformatted (json_obj);
98
+
99
+ res.set_status (SC_HTTP_BAD_REQUEST);
100
+ cJSON_Delete (json_obj);
101
+ } else {
102
+ api_mam_send_message (&ta_core.tangle , &ta_core.service ,
103
+ req.body ().c_str (), &json_result, &chid_result);
104
+ ret = set_response_content (ret, &json_result);
105
+ res.set_status (ret);
106
+ }
107
+
108
+ set_method_header (res, HTTP_METHOD_POST);
109
+ res << json_result;
110
+ });
111
+
82
112
/* *
83
113
* @method {get} /tag/:tag Find transactions by tag
84
114
*
You can’t perform that action at this time.
0 commit comments