Skip to content

Commit f88520d

Browse files
committed
experimenting with some refactoring
1 parent a0d6524 commit f88520d

37 files changed

+275
-172
lines changed

src/APSettingsService.cpp renamed to lib/framework/APSettingsService.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#include <APSettingsService.h>
22

3-
APSettingsService::APSettingsService(AsyncWebServer* server, FS* fs, SecurityManager* securityManager) : AdminSettingsService(server, fs, securityManager, AP_SETTINGS_SERVICE_PATH, AP_SETTINGS_FILE) {
3+
APSettingsService::APSettingsService(FS* fs, SecurityManager* securityManager) : AdminSettingsService(fs, securityManager, AP_SETTINGS_SERVICE_PATH, AP_SETTINGS_FILE) {
44
onConfigUpdated();
55
}
66

src/APSettingsService.h renamed to lib/framework/APSettingsService.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class APSettingsService : public AdminSettingsService {
2323

2424
public:
2525

26-
APSettingsService(AsyncWebServer* server, FS* fs, SecurityManager* securityManager);
26+
APSettingsService(FS* fs, SecurityManager* securityManager);
2727
~APSettingsService();
2828

2929
void loop();

src/APStatus.cpp renamed to lib/framework/APStatus.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
#include <APStatus.h>
22

3-
APStatus::APStatus(AsyncWebServer *server, SecurityManager* securityManager) : _server(server), _securityManager(securityManager) {
4-
_server->on(AP_STATUS_SERVICE_PATH, HTTP_GET,
3+
APStatus::APStatus(SecurityManager* securityManager) :_securityManager(securityManager) {}
4+
5+
void APStatus::init(AsyncWebServer *server){
6+
server->on(AP_STATUS_SERVICE_PATH, HTTP_GET,
57
_securityManager->wrapRequest(std::bind(&APStatus::apStatus, this, std::placeholders::_1), AuthenticationPredicates::IS_AUTHENTICATED)
68
);
79
}

src/APStatus.h renamed to lib/framework/APStatus.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ class APStatus {
2222

2323
public:
2424

25-
APStatus(AsyncWebServer *server, SecurityManager* securityManager);
25+
APStatus(SecurityManager* securityManager);
26+
void init(AsyncWebServer *server);
2627

2728
private:
28-
29-
AsyncWebServer* _server;
29+
3030
SecurityManager* _securityManager;
3131

3232
void apStatus(AsyncWebServerRequest *request);
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

src/AuthenticationService.cpp renamed to lib/framework/AuthenticationService.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
#include <AuthenticationService.h>
22

3-
AuthenticationService::AuthenticationService(AsyncWebServer* server, SecurityManager* securityManager):
4-
_server(server), _securityManager(securityManager) {
5-
server->on(VERIFY_AUTHORIZATION_PATH, HTTP_GET, std::bind(&AuthenticationService::verifyAuthorization, this, std::placeholders::_1));
6-
3+
AuthenticationService::AuthenticationService(SecurityManager* securityManager) : _securityManager(securityManager) {
74
_signInHandler.setUri(SIGN_IN_PATH);
85
_signInHandler.setMethod(HTTP_POST);
96
_signInHandler.setMaxContentLength(MAX_AUTHENTICATION_SIZE);
107
_signInHandler.onRequest(std::bind(&AuthenticationService::signIn, this, std::placeholders::_1, std::placeholders::_2));
11-
server->addHandler(&_signInHandler);
128
}
139

1410
AuthenticationService::~AuthenticationService() {}
1511

12+
void AuthenticationService::init(AsyncWebServer* server) {
13+
server->on(VERIFY_AUTHORIZATION_PATH, HTTP_GET, std::bind(&AuthenticationService::verifyAuthorization, this, std::placeholders::_1));
14+
server->addHandler(&_signInHandler);
15+
}
16+
1617
/**
1718
* Verifys that the request supplied a valid JWT.
1819
*/

src/AuthenticationService.h renamed to lib/framework/AuthenticationService.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,11 @@ class AuthenticationService {
1515

1616
public:
1717

18-
AuthenticationService(AsyncWebServer* server, SecurityManager* securityManager) ;
18+
AuthenticationService(SecurityManager* securityManager);
1919
~AuthenticationService();
2020

21+
void init(AsyncWebServer* server);
22+
2123
private:
2224
// server instance
2325
AsyncWebServer* _server;

0 commit comments

Comments
 (0)