Skip to content

Commit a90a145

Browse files
Remove ClientType from all templates, auto-infer
Remove the ClientType template parameter from all objects. Simplifies the code and makes it more foolproof. Add a "using" in each server to define the type of connection returned by all servers, which is then used in the above templates automatically.
1 parent 8a3e3eb commit a90a145

File tree

11 files changed

+164
-158
lines changed

11 files changed

+164
-158
lines changed

libraries/ESP8266HTTPUpdateServer/src/ESP8266HTTPUpdateServer-impl.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ static const char serverIndex[] PROGMEM =
1616
static const char successResponse[] PROGMEM =
1717
"<META http-equiv=\"refresh\" content=\"15;URL=/\">Update Success! Rebooting...\n";
1818

19-
template <typename ServerType, typename ClientType>
20-
ESP8266HTTPUpdateServerTemplate<ServerType, ClientType>::ESP8266HTTPUpdateServerTemplate(bool serial_debug)
19+
template <typename ServerType>
20+
ESP8266HTTPUpdateServerTemplate<ServerType>::ESP8266HTTPUpdateServerTemplate(bool serial_debug)
2121
{
2222
_serial_output = serial_debug;
2323
_server = NULL;
@@ -26,8 +26,8 @@ ESP8266HTTPUpdateServerTemplate<ServerType, ClientType>::ESP8266HTTPUpdateServer
2626
_authenticated = false;
2727
}
2828

29-
template <typename ServerType, typename ClientType>
30-
void ESP8266HTTPUpdateServerTemplate<ServerType, ClientType>::setup(ESP8266WebServerTemplate<ServerType, ClientType> *server, const String& path, const String& username, const String& password)
29+
template <typename ServerType>
30+
void ESP8266HTTPUpdateServerTemplate<ServerType>::setup(ESP8266WebServerTemplate<ServerType> *server, const String& path, const String& username, const String& password)
3131
{
3232
_server = server;
3333
_username = username;
@@ -97,8 +97,8 @@ void ESP8266HTTPUpdateServerTemplate<ServerType, ClientType>::setup(ESP8266WebSe
9797
});
9898
}
9999

100-
template <typename ServerType, typename ClientType>
101-
void ESP8266HTTPUpdateServerTemplate<ServerType, ClientType>::_setUpdaterError()
100+
template <typename ServerType>
101+
void ESP8266HTTPUpdateServerTemplate<ServerType>::_setUpdaterError()
102102
{
103103
if (_serial_output) Update.printError(Serial);
104104
StreamString str;

libraries/ESP8266HTTPUpdateServer/src/ESP8266HTTPUpdateServer.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,28 @@
33

44
#include <ESP8266WebServer.h>
55

6-
template <typename ServerType, typename ClientType>
6+
template <typename ServerType>
77
class ESP8266HTTPUpdateServerTemplate
88
{
99
public:
1010
ESP8266HTTPUpdateServerTemplate(bool serial_debug=false);
1111

12-
void setup(ESP8266WebServerTemplate<ServerType, ClientType> *server)
12+
void setup(ESP8266WebServerTemplate<ServerType> *server)
1313
{
1414
setup(server, emptyString, emptyString);
1515
}
1616

17-
void setup(ESP8266WebServerTemplate<ServerType, ClientType> *server, const String& path)
17+
void setup(ESP8266WebServerTemplate<ServerType> *server, const String& path)
1818
{
1919
setup(server, path, emptyString, emptyString);
2020
}
2121

22-
void setup(ESP8266WebServerTemplate<ServerType, ClientType> *server, const String& username, const String& password)
22+
void setup(ESP8266WebServerTemplate<ServerType> *server, const String& username, const String& password)
2323
{
2424
setup(server, "/update", username, password);
2525
}
2626

27-
void setup(ESP8266WebServerTemplate<ServerType, ClientType> *server, const String& path, const String& username, const String& password);
27+
void setup(ESP8266WebServerTemplate<ServerType> *server, const String& path, const String& username, const String& password);
2828

2929
void updateCredentials(const String& username, const String& password)
3030
{
@@ -37,7 +37,7 @@ class ESP8266HTTPUpdateServerTemplate
3737

3838
private:
3939
bool _serial_output;
40-
ESP8266WebServerTemplate<ServerType, ClientType> *_server;
40+
ESP8266WebServerTemplate<ServerType> *_server;
4141
String _username;
4242
String _password;
4343
bool _authenticated;
@@ -47,14 +47,14 @@ class ESP8266HTTPUpdateServerTemplate
4747
#include "ESP8266HTTPUpdateServer-impl.h"
4848

4949

50-
using ESP8266HTTPUpdateServer = ESP8266HTTPUpdateServerTemplate<WiFiServer, WiFiClient>;
50+
using ESP8266HTTPUpdateServer = ESP8266HTTPUpdateServerTemplate<WiFiServer>;
5151

5252
namespace BearSSL {
53-
using ESP8266HTTPUpdateServerSecure = ESP8266HTTPUpdateServerTemplate<WiFiServerSecure, WiFiClientSecure>;
53+
using ESP8266HTTPUpdateServerSecure = ESP8266HTTPUpdateServerTemplate<WiFiServerSecure>;
5454
};
5555

5656
namespace axTLS {
57-
using ESP8266HTTPUpdateServerSecure = ESP8266HTTPUpdateServerTemplate<WiFiServerSecure, WiFiClientSecure>;
57+
using ESP8266HTTPUpdateServerSecure = ESP8266HTTPUpdateServerTemplate<WiFiServerSecure>;
5858
};
5959

6060
#endif

0 commit comments

Comments
 (0)