11
11
12
12
#define HTTP_ENDPOINT_ORIGIN_ID " http"
13
13
14
+ using namespace std ::placeholders; // for `_1` etc
15
+
14
16
template <class T >
15
17
class HttpGetEndpoint {
16
18
public:
@@ -24,20 +26,14 @@ class HttpGetEndpoint {
24
26
: _stateReader(stateReader)
25
27
, _statefulService(statefulService)
26
28
, _bufferSize(bufferSize) {
27
- server->on (servicePath.c_str (),
28
- HTTP_GET,
29
- securityManager->wrapRequest (std::bind (&HttpGetEndpoint::fetchSettings, this , std::placeholders::_1), authenticationPredicate));
29
+ server->on (servicePath.c_str (), HTTP_GET, securityManager->wrapRequest (std::bind (&HttpGetEndpoint::fetchSettings, this , _1), authenticationPredicate));
30
30
}
31
31
32
- HttpGetEndpoint (JsonStateReader<T> stateReader,
33
- StatefulService<T> * statefulService,
34
- AsyncWebServer * server,
35
- const String & servicePath,
36
- size_t bufferSize = DEFAULT_BUFFER_SIZE)
32
+ HttpGetEndpoint (JsonStateReader<T> stateReader, StatefulService<T> * statefulService, AsyncWebServer * server, const String & servicePath, size_t bufferSize = DEFAULT_BUFFER_SIZE)
37
33
: _stateReader(stateReader)
38
34
, _statefulService(statefulService)
39
35
, _bufferSize(bufferSize) {
40
- server->on (servicePath.c_str (), HTTP_GET, std::bind (&HttpGetEndpoint::fetchSettings, this , std::placeholders:: _1));
36
+ server->on (servicePath.c_str (), HTTP_GET, std::bind (&HttpGetEndpoint::fetchSettings, this , _1));
41
37
}
42
38
43
39
protected:
@@ -69,25 +65,17 @@ class HttpPostEndpoint {
69
65
: _stateReader(stateReader)
70
66
, _stateUpdater(stateUpdater)
71
67
, _statefulService(statefulService)
72
- , _updateHandler(servicePath,
73
- securityManager->wrapCallback (std::bind(&HttpPostEndpoint::updateSettings, this , std::placeholders::_1, std::placeholders::_2),
74
- authenticationPredicate),
75
- bufferSize)
68
+ , _updateHandler(servicePath, securityManager->wrapCallback (std::bind(&HttpPostEndpoint::updateSettings, this , _1, _2), authenticationPredicate), bufferSize)
76
69
, _bufferSize(bufferSize) {
77
70
_updateHandler.setMethod (HTTP_POST);
78
71
server->addHandler (&_updateHandler);
79
72
}
80
73
81
- HttpPostEndpoint (JsonStateReader<T> stateReader,
82
- JsonStateUpdater<T> stateUpdater,
83
- StatefulService<T> * statefulService,
84
- AsyncWebServer * server,
85
- const String & servicePath,
86
- size_t bufferSize = DEFAULT_BUFFER_SIZE)
74
+ HttpPostEndpoint (JsonStateReader<T> stateReader, JsonStateUpdater<T> stateUpdater, StatefulService<T> * statefulService, AsyncWebServer * server, const String & servicePath, size_t bufferSize = DEFAULT_BUFFER_SIZE)
87
75
: _stateReader(stateReader)
88
76
, _stateUpdater(stateUpdater)
89
77
, _statefulService(statefulService)
90
- , _updateHandler(servicePath, std::bind(&HttpPostEndpoint::updateSettings, this , std::placeholders:: _1, std::placeholders:: _2), bufferSize)
78
+ , _updateHandler(servicePath, std::bind(&HttpPostEndpoint::updateSettings, this , _1, _2), bufferSize)
91
79
, _bufferSize(bufferSize) {
92
80
_updateHandler.setMethod (HTTP_POST);
93
81
server->addHandler (&_updateHandler);
@@ -137,12 +125,7 @@ class HttpEndpoint : public HttpGetEndpoint<T>, public HttpPostEndpoint<T> {
137
125
, HttpPostEndpoint<T>(stateReader, stateUpdater, statefulService, server, servicePath, securityManager, authenticationPredicate, bufferSize) {
138
126
}
139
127
140
- HttpEndpoint (JsonStateReader<T> stateReader,
141
- JsonStateUpdater<T> stateUpdater,
142
- StatefulService<T> * statefulService,
143
- AsyncWebServer * server,
144
- const String & servicePath,
145
- size_t bufferSize = DEFAULT_BUFFER_SIZE)
128
+ HttpEndpoint (JsonStateReader<T> stateReader, JsonStateUpdater<T> stateUpdater, StatefulService<T> * statefulService, AsyncWebServer * server, const String & servicePath, size_t bufferSize = DEFAULT_BUFFER_SIZE)
146
129
: HttpGetEndpoint<T>(stateReader, statefulService, server, servicePath, bufferSize)
147
130
, HttpPostEndpoint<T>(stateReader, stateUpdater, statefulService, server, servicePath, bufferSize) {
148
131
}
0 commit comments