8000 fix formatting issue · adityathakekar/esp8266-react@f5533b6 · GitHub
[go: up one dir, main page]

Skip to content

Commit f5533b6

Browse files
committed
fix formatting issue
1 parent 243e1b3 commit f5533b6

File tree

1 file changed

+27
-33
lines changed

1 file changed

+27
-33
lines changed

lib/framework/SettingsService.h

Lines changed: 27 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -20,67 +20,61 @@
2020
/*
2121
* Abstraction of a service which stores it's settings as JSON in a file system.
2222
*/
23-
class SettingsService : public SettingsPersistence
24-
{
23+
class SettingsService : public SettingsPersistence {
2524

26-
public:
27-
SettingsService(AsyncWebServer *server, FS *fs, char const *servicePath, char const *filePath) : SettingsPersistence(fs, filePath), _servicePath(servicePath)
28-
{
29-
server->on(_servicePath, HTTP_GET, std::bind(&SettingsService::fetchConfig, this, std::placeholders::_1));
25+
public:
3026

31-
_updateHandler.setUri(servicePath);
32-
_updateHandler.setMethod(HTTP_POST);
33-
_updateHandler.setMaxContentLength(MAX_SETTINGS_SIZE);
34-
_updateHandler.onRequest(std::bind(&SettingsService::updateConfig, this, std::placeholders::_1, std::placeholders::_2));
35-
server->addHandler(&_updateHandler);
36-
}
27+
SettingsService(AsyncWebServer* server, FS* fs, char const* servicePath, char const* filePath): SettingsPersistence(fs, filePath), _servicePath(servicePath) {
28+
server->on(_servicePath, HTTP_GET, std::bind(&SettingsService::fetchConfig, this, std::placeholders::_1));
3729

38-
virtual ~SettingsService() {}
30+
_updateHandler.setUri(servicePath);
31+
_updateHandler.setMethod(HTTP_POST);
32+
_updateHandler.setMaxContentLength(MAX_SETTINGS_SIZE);
33+
_updateHandler.onRequest(std::bind(&SettingsService::updateConfig, this, std::placeholders::_1, std::placeholders::_2));
34+
server->addHandler(&_updateHandler);
35+
}
3936

40-
void begin()
41-
{
42-
// read the initial data from the file system
43-
readFromFS();
44-
}
37+
virtual ~SettingsService() {}
38+
39+
void begin() {
40+
// read the initial data from the file system
41+
readFromFS();
42+
}
4543

4644
protected:
47-
char const *_servicePath;
45+
char const* _servicePath;
4846
AsyncJsonWebHandler _updateHandler;
4947

50-
virtual void fetchConfig(AsyncWebServerRequest *request)
51-
{
48+
virtual void fetchConfig(AsyncWebServerRequest *request) {
5249
// handle the request
53-
AsyncJsonResponse *response = new AsyncJsonResponse(false, MAX_SETTINGS_SIZE);
54-
JsonObject jsonObject = response->getRoot();
50+
AsyncJsonResponse * response = new AsyncJsonResponse(false, MAX_SETTINGS_SIZE);
51+
JsonObject jsonObject = response->getRoot();
5552
writeToJsonObject(jsonObject);
5653
response->setLength();
5754
request->send(response);
5855
}
5956

60-
virtual void updateConfig(AsyncWebServerRequest *request, JsonDocument &jsonDocument)
61-
{
57+
virtual void updateConfig(AsyncWebServerRequest *request, JsonDocument &jsonDocument) {
6258
// handle the request
63-
if (jsonDocument.is<JsonObject>())
64-
{
59+
if (jsonDocument.is<JsonObject>()){
6560
JsonObject newConfig = jsonDocument.as<JsonObject>();
6661
readFromJsonObject(newConfig);
6762
writeToFS();
6863

6964
// write settings back with a callback to reconfigure the wifi
70-
AsyncJsonCallbackResponse *response = new AsyncJsonCallbackResponse([this]() { onConfigUpdated(); }, false, MAX_SETTINGS_SIZE);
71-
JsonObject jsonObject = response->getRoot();
65+
AsyncJsonCallbackResponse * response = new AsyncJsonCallbackResponse([this] () {onConfigUpdated();}, false, MAX_SETTINGS_SIZE);
66+
JsonObject jsonObject = response->getRoot();
7267
writeToJsonObject(jsonObject);
7368
response->setLength();
7469
request->send(response);
75-
}
76-
else
77-
{
70+
} else {
7871
request->send(400);
7972
}
8073
}
8174

8275
// implement to perform action when config has been updated
83-
virtual void onConfigUpdated() {}
76+
virtual void onConfigUpdated(){}
77+
8478
};
8579

8680
#endif // end SettingsService

0 commit comments

Comments
 (0)
0