remove & reference to JsonVariant (prevent dangling references)

This commit is contained in:
Proddy
2024-01-08 11:32:58 +01:00
parent ad9e463923
commit 3f10523e66
18 changed files with 28 additions and 28 deletions

View File

@@ -70,7 +70,7 @@ class MsgpackAsyncJsonResponse : public AsyncAbstractResponse {
~MsgpackAsyncJsonResponse() {
}
JsonVariant & getRoot() {
JsonVariant getRoot() {
return _root;
}
bool _sourceValid() const {
@@ -114,7 +114,7 @@ class AsyncJsonResponse : public AsyncAbstractResponse {
~AsyncJsonResponse() {
}
JsonVariant & getRoot() {
JsonVariant getRoot() {
return _root;
}
bool _sourceValid() const {
@@ -158,7 +158,7 @@ class PrettyAsyncJsonResponse : public AsyncJsonResponse {
}
};
typedef std::function<void(AsyncWebServerRequest * request, JsonVariant & json)> ArJsonRequestHandlerFunction;
typedef std::function<void(AsyncWebServerRequest * request, JsonVariant json)> ArJsonRequestHandlerFunction;
class AsyncCallbackJsonWebHandler : public AsyncWebHandler {
private:

View File

@@ -25,7 +25,7 @@ void AuthenticationService::verifyAuthorization(AsyncWebServerRequest * request)
* Signs in a user if the username and password match. Provides a JWT to be used in the Authorization header in
* subsequent requests.
*/
void AuthenticationService::signIn(AsyncWebServerRequest * request, JsonVariant & json) {
void AuthenticationService::signIn(AsyncWebServerRequest * request, JsonVariant json) {
if (json.is<JsonObject>()) {
String username = json["username"];
String password = json["password"];

View File

@@ -21,7 +21,7 @@ class AuthenticationService {
AsyncCallbackJsonWebHandler _signInHandler;
// endpoint functions
void signIn(AsyncWebServerRequest * request, JsonVariant & json);
void signIn(AsyncWebServerRequest * request, JsonVariant json);
void verifyAuthorization(AsyncWebServerRequest * request);
};

View File

@@ -83,7 +83,7 @@ class HttpPostEndpoint {
StatefulService<T> * _statefulService;
AsyncCallbackJsonWebHandler _updateHandler;
void updateSettings(AsyncWebServerRequest * request, JsonVariant & json) {
void updateSettings(AsyncWebServerRequest * request, JsonVariant json) {
if (!json.is<JsonObject>()) {
request->send(400);
return;

View File

@@ -61,7 +61,7 @@ void NTPSettingsService::configureNTP() {
}
}
void NTPSettingsService::configureTime(AsyncWebServerRequest * request, JsonVariant & json) {
void NTPSettingsService::configureTime(AsyncWebServerRequest * request, JsonVariant json) {
if (json.is<JsonObject>()) {
struct tm tm = {0};
String timeLocal = json["local_time"];

View File

@@ -67,7 +67,7 @@ class NTPSettingsService : public StatefulService<NTPSettings> {
bool connected_ = false;
void WiFiEvent(WiFiEvent_t event);
void configureNTP();
void configureTime(AsyncWebServerRequest * request, JsonVariant & json);
void configureTime(AsyncWebServerRequest * request, JsonVariant json);
};
#endif

View File

@@ -101,7 +101,7 @@ ArRequestHandlerFunction SecuritySettingsService::wrapRequest(ArRequestHandlerFu
}
ArJsonRequestHandlerFunction SecuritySettingsService::wrapCallback(ArJsonRequestHandlerFunction onRequest, AuthenticationPredicate predicate) {
return [this, onRequest, predicate](AsyncWebServerRequest * request, JsonVariant & json) {
return [this, onRequest, predicate](AsyncWebServerRequest * request, JsonVariant json) {
Authentication authentication = authenticateRequest(request);
if (!predicate(authentication)) {
request->send(401);