Add text responses as json with msg key

This commit is contained in:
Tobias Reisinger 2020-11-13 23:20:07 +01:00
parent f97b149376
commit 1d6e8ff037
18 changed files with 114 additions and 83 deletions
src/endpoints

View file

@ -34,7 +34,7 @@ api_v1_schedules_POST(struct mg_connection *nc, struct http_message *hm, endpoin
{
cJSON_Delete(json);
M_RESPONSE_TEXT_STATIC(LOGGER_DEBUG, response, 400, "the request does not contain periods");
M_RESPONSE_MSG(LOGGER_DEBUG, response, 400, "the request does not contain periods");
return;
}
@ -46,7 +46,7 @@ api_v1_schedules_POST(struct mg_connection *nc, struct http_message *hm, endpoin
{
cJSON_Delete(json);
M_RESPONSE_TEXT_STATIC(LOGGER_DEBUG, response, 400, "the request contains at least one invalid tag");
M_RESPONSE_MSG(LOGGER_DEBUG, response, 400, "the request contains at least one invalid tag");
return;
}
}
@ -75,7 +75,7 @@ api_v1_schedules_POST(struct mg_connection *nc, struct http_message *hm, endpoin
cJSON_Delete(json);
schedule_free(new_schedule);
M_RESPONSE_TEXT_STATIC(LOGGER_DEBUG, response, 400, "the request contains at least one period without a start");
M_RESPONSE_MSG(LOGGER_DEBUG, response, 400, "the request contains at least one period without a start");
return;
}
if(!cJSON_IsString(json_period_end) || (json_period_end->valuestring == NULL))
@ -83,7 +83,7 @@ api_v1_schedules_POST(struct mg_connection *nc, struct http_message *hm, endpoin
cJSON_Delete(json);
schedule_free(new_schedule);
M_RESPONSE_TEXT_STATIC(LOGGER_DEBUG, response, 400, "the request contains at least one period without an end");
M_RESPONSE_MSG(LOGGER_DEBUG, response, 400, "the request contains at least one period without an end");
return;
}
@ -94,7 +94,7 @@ api_v1_schedules_POST(struct mg_connection *nc, struct http_message *hm, endpoin
cJSON_Delete(json);
schedule_free(new_schedule);
M_RESPONSE_TEXT_STATIC(LOGGER_DEBUG, response, 400, "the request contains at least one period with an invalid start");
M_RESPONSE_MSG(LOGGER_DEBUG, response, 400, "the request contains at least one period with an invalid start");
return;
}
if(period_helper_parse_hhmm(json_period_end->valuestring, &end))
@ -102,7 +102,7 @@ api_v1_schedules_POST(struct mg_connection *nc, struct http_message *hm, endpoin
cJSON_Delete(json);
schedule_free(new_schedule);
M_RESPONSE_TEXT_STATIC(LOGGER_DEBUG, response, 400, "the request contains at least one period with an invalid end");
M_RESPONSE_MSG(LOGGER_DEBUG, response, 400, "the request contains at least one period with an invalid end");
return;
}