1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-04-22 21:23:07 +03:00

Avoid #includes with a surrounding namespace (#7560)

untangle the namespace/double inclusions in webserver library.
This is a followup of the discussion in
https://github.com/esp8266/Arduino/pull/6946#discussion_r361582525
This commit is contained in:
Dirk Mueller 2020-09-17 15:35:27 +02:00 committed by GitHub
parent e5c84c9503
commit 32470fbfab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 20 additions and 4 deletions

View File

@ -34,6 +34,8 @@ static const char qop_auth_quoted[] PROGMEM = "qop=\"auth\"";
static const char WWW_Authenticate[] PROGMEM = "WWW-Authenticate";
static const char Content_Length[] PROGMEM = "Content-Length";
namespace esp8266webserver {
template <typename ServerType>
ESP8266WebServerTemplate<ServerType>::ESP8266WebServerTemplate(IPAddress addr, int port)
: _server(addr, port)
@ -864,3 +866,5 @@ String ESP8266WebServerTemplate<ServerType>::responseCodeToString(const int code
}
return String(r);
}
} // namespace

View File

@ -82,8 +82,12 @@ namespace esp8266webserver {
template<typename ServerType>
class ESP8266WebServerTemplate;
}
#include "detail/RequestHandler.h"
namespace esp8266webserver {
template<typename ServerType>
class ESP8266WebServerTemplate
{
@ -296,13 +300,11 @@ protected:
HookFunction _hook;
};
} // namespace
#include "ESP8266WebServer-impl.h"
#include "Parsing-impl.h"
};
using ESP8266WebServer = esp8266webserver::ESP8266WebServerTemplate<WiFiServer>;
using RequestHandler = esp8266webserver::RequestHandler<WiFiServer>;

View File

@ -32,6 +32,8 @@
static const char Content_Type[] PROGMEM = "Content-Type";
static const char filename[] PROGMEM = "filename";
namespace esp8266webserver {
template <typename ServerType>
static bool readBytesWithTimeout(typename ServerType::ClientType& client, size_t maxLength, String& data, int timeout_ms)
{
@ -578,3 +580,5 @@ bool ESP8266WebServerTemplate<ServerType>::_parseFormUploadAborted(){
_currentHandler->upload(*this, _currentUri, *_currentUpload);
return false;
}
} // namespace

View File

@ -5,6 +5,8 @@
#include <vector>
#include <assert.h>
namespace esp8266webserver {
template<typename ServerType>
class RequestHandler {
using WebServerType = ESP8266WebServerTemplate<ServerType>;
@ -31,4 +33,6 @@ public:
}
};
} // namespace
#endif //REQUESTHANDLER_H

View File

@ -7,7 +7,7 @@
#include "WString.h"
#include "Uri.h"
using namespace mime;
namespace esp8266webserver {
template<typename ServerType>
class FunctionRequestHandler : public RequestHandler<ServerType> {
@ -126,6 +126,7 @@ public:
String contentType = mime::getContentType(path);
using namespace mime;
// look for gz file, only if the original specified path is not a gz. So part only works to send gzip via content encoding when a non compressed is asked for
// if you point the the path to gzip you will serve the gzip as content type "application/x-gzip", not text or javascript etc...
if (!path.endsWith(FPSTR(mimeTable[gz].endsWith)) && !_fs.exists(path)) {
@ -164,5 +165,6 @@ protected:
size_t _baseUriLength;
};
} // namespace
#endif //REQUESTHANDLERSIMPL_H