mirror of
https://github.com/esp8266/Arduino.git
synced 2025-04-19 23:22:16 +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:
parent
e5c84c9503
commit
32470fbfab
@ -34,6 +34,8 @@ static const char qop_auth_quoted[] PROGMEM = "qop=\"auth\"";
|
|||||||
static const char WWW_Authenticate[] PROGMEM = "WWW-Authenticate";
|
static const char WWW_Authenticate[] PROGMEM = "WWW-Authenticate";
|
||||||
static const char Content_Length[] PROGMEM = "Content-Length";
|
static const char Content_Length[] PROGMEM = "Content-Length";
|
||||||
|
|
||||||
|
namespace esp8266webserver {
|
||||||
|
|
||||||
template <typename ServerType>
|
template <typename ServerType>
|
||||||
ESP8266WebServerTemplate<ServerType>::ESP8266WebServerTemplate(IPAddress addr, int port)
|
ESP8266WebServerTemplate<ServerType>::ESP8266WebServerTemplate(IPAddress addr, int port)
|
||||||
: _server(addr, port)
|
: _server(addr, port)
|
||||||
@ -864,3 +866,5 @@ String ESP8266WebServerTemplate<ServerType>::responseCodeToString(const int code
|
|||||||
}
|
}
|
||||||
return String(r);
|
return String(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
@ -82,8 +82,12 @@ namespace esp8266webserver {
|
|||||||
template<typename ServerType>
|
template<typename ServerType>
|
||||||
class ESP8266WebServerTemplate;
|
class ESP8266WebServerTemplate;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
#include "detail/RequestHandler.h"
|
#include "detail/RequestHandler.h"
|
||||||
|
|
||||||
|
namespace esp8266webserver {
|
||||||
|
|
||||||
template<typename ServerType>
|
template<typename ServerType>
|
||||||
class ESP8266WebServerTemplate
|
class ESP8266WebServerTemplate
|
||||||
{
|
{
|
||||||
@ -296,13 +300,11 @@ protected:
|
|||||||
HookFunction _hook;
|
HookFunction _hook;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
#include "ESP8266WebServer-impl.h"
|
#include "ESP8266WebServer-impl.h"
|
||||||
#include "Parsing-impl.h"
|
#include "Parsing-impl.h"
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
using ESP8266WebServer = esp8266webserver::ESP8266WebServerTemplate<WiFiServer>;
|
using ESP8266WebServer = esp8266webserver::ESP8266WebServerTemplate<WiFiServer>;
|
||||||
using RequestHandler = esp8266webserver::RequestHandler<WiFiServer>;
|
using RequestHandler = esp8266webserver::RequestHandler<WiFiServer>;
|
||||||
|
|
||||||
|
@ -32,6 +32,8 @@
|
|||||||
static const char Content_Type[] PROGMEM = "Content-Type";
|
static const char Content_Type[] PROGMEM = "Content-Type";
|
||||||
static const char filename[] PROGMEM = "filename";
|
static const char filename[] PROGMEM = "filename";
|
||||||
|
|
||||||
|
namespace esp8266webserver {
|
||||||
|
|
||||||
template <typename ServerType>
|
template <typename ServerType>
|
||||||
static bool readBytesWithTimeout(typename ServerType::ClientType& client, size_t maxLength, String& data, int timeout_ms)
|
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);
|
_currentHandler->upload(*this, _currentUri, *_currentUpload);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
@ -5,6 +5,8 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
|
namespace esp8266webserver {
|
||||||
|
|
||||||
template<typename ServerType>
|
template<typename ServerType>
|
||||||
class RequestHandler {
|
class RequestHandler {
|
||||||
using WebServerType = ESP8266WebServerTemplate<ServerType>;
|
using WebServerType = ESP8266WebServerTemplate<ServerType>;
|
||||||
@ -31,4 +33,6 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
#endif //REQUESTHANDLER_H
|
#endif //REQUESTHANDLER_H
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
#include "WString.h"
|
#include "WString.h"
|
||||||
#include "Uri.h"
|
#include "Uri.h"
|
||||||
|
|
||||||
using namespace mime;
|
namespace esp8266webserver {
|
||||||
|
|
||||||
template<typename ServerType>
|
template<typename ServerType>
|
||||||
class FunctionRequestHandler : public RequestHandler<ServerType> {
|
class FunctionRequestHandler : public RequestHandler<ServerType> {
|
||||||
@ -126,6 +126,7 @@ public:
|
|||||||
|
|
||||||
String contentType = mime::getContentType(path);
|
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
|
// 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 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)) {
|
if (!path.endsWith(FPSTR(mimeTable[gz].endsWith)) && !_fs.exists(path)) {
|
||||||
@ -164,5 +165,6 @@ protected:
|
|||||||
size_t _baseUriLength;
|
size_t _baseUriLength;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
#endif //REQUESTHANDLERSIMPL_H
|
#endif //REQUESTHANDLERSIMPL_H
|
||||||
|
Loading…
x
Reference in New Issue
Block a user