Hello,
i have established Async Server listening to port, and received JSON data, parse them and then needs to return a response to client by adding headers and route/path to which will yield a successful acknowledgement.
but unfortunately i found arguments in have only (HTTPCODE, "Content-Type", Message), then how can i add client path (example, POST /clientROUTE HTTP/1.1)?
here is my main part of code, needs help.
serverWeb.on(
"/",
HTTP_POST,
[](AsyncWebServerRequest * request){},
NULL,
[](AsyncWebServerRequest * request, uint8_t *data, size_t len, size_t index, size_t total) {
for (size_t i = 0; i < len; i++) {
Serial.write(data[i]);
}
Serial.println();
// Serial.print("Data:");
// Serial.println((const char*)data);
String c = (const char*)data;
if(ptsFunction(c)){
Serial.println("\nSUCCESS");
//send back to client
char* requestClient = (char ) ps_malloc(101024 * sizeof(char));
sprintf(requestClient,"{"A":"AA","B":%d}",i);
Serial.println(F("send back to Client response"));
AsyncWebServerResponse *response = request->beginResponse(200, "Content-Type: application/json", String(requestClient).c_str());
response->addHeader("header1", "Value1");
response->addHeader("header2", "Value2");
response->addHeader("header3", "Value3");
request->send(response);
});