28 lines
720 B
C++
28 lines
720 B
C++
|
#include "EspHttp.h"
|
||
|
|
||
|
esp_err_t rawCallback(httpd_req_t *req)
|
||
|
{
|
||
|
EspHttp::Callback *userCb = (EspHttp::Callback *)(req->user_ctx);
|
||
|
(*userCb)(req);
|
||
|
return ESP_OK;
|
||
|
}
|
||
|
|
||
|
int getUrlQueryParameter(httpd_req_t *req, const char *name, int defaultValue)
|
||
|
{
|
||
|
size_t bufferLength = httpd_req_get_url_query_len(req) + 1;
|
||
|
int result = defaultValue;
|
||
|
if (bufferLength > 1)
|
||
|
{
|
||
|
char* buf = (char*)malloc(bufferLength);
|
||
|
if (httpd_req_get_url_query_str(req, buf, bufferLength) == ESP_OK)
|
||
|
{
|
||
|
char param[32];
|
||
|
/* Get value of expected key from query string */
|
||
|
if (httpd_query_key_value(buf, name, param, sizeof(param)) == ESP_OK)
|
||
|
result = atoi(param);
|
||
|
}
|
||
|
free(buf);
|
||
|
}
|
||
|
return result;
|
||
|
}
|