Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid #includes with a surrounding namespace #7560

Merged
merged 2 commits into from
Sep 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions libraries/ESP8266WebServer/src/ESP8266WebServer-impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -864,3 +866,5 @@ String ESP8266WebServerTemplate<ServerType>::responseCodeToString(const int code
}
return String(r);
}

} // namespace
8 changes: 5 additions & 3 deletions libraries/ESP8266WebServer/src/ESP8266WebServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,12 @@ namespace esp8266webserver {
template<typename ServerType>
class ESP8266WebServerTemplate;

}

#include "detail/RequestHandler.h"

namespace esp8266webserver {

template<typename ServerType>
class ESP8266WebServerTemplate
{
Expand Down Expand Up @@ -296,13 +300,11 @@ class ESP8266WebServerTemplate
HookFunction _hook;
};

} // namespace

#include "ESP8266WebServer-impl.h"
#include "Parsing-impl.h"

};


using ESP8266WebServer = esp8266webserver::ESP8266WebServerTemplate<WiFiServer>;
using RequestHandler = esp8266webserver::RequestHandler<WiFiServer>;

Expand Down
4 changes: 4 additions & 0 deletions libraries/ESP8266WebServer/src/Parsing-impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -578,3 +580,5 @@ bool ESP8266WebServerTemplate<ServerType>::_parseFormUploadAborted(){
_currentHandler->upload(*this, _currentUri, *_currentUpload);
return false;
}

} // namespace
4 changes: 4 additions & 0 deletions libraries/ESP8266WebServer/src/detail/RequestHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
#include <vector>
#include <assert.h>

namespace esp8266webserver {

template<typename ServerType>
class RequestHandler {
using WebServerType = ESP8266WebServerTemplate<ServerType>;
Expand All @@ -31,4 +33,6 @@ class RequestHandler {
}
};

} // namespace

#endif //REQUESTHANDLER_H
4 changes: 3 additions & 1 deletion libraries/ESP8266WebServer/src/detail/RequestHandlersImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include "WString.h"
#include "Uri.h"

using namespace mime;
namespace esp8266webserver {

template<typename ServerType>
class FunctionRequestHandler : public RequestHandler<ServerType> {
Expand Down Expand Up @@ -126,6 +126,7 @@ class StaticRequestHandler : public RequestHandler<ServerType> {

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)) {
Expand Down Expand Up @@ -164,5 +165,6 @@ class StaticRequestHandler : public RequestHandler<ServerType> {
size_t _baseUriLength;
};

} // namespace

#endif //REQUESTHANDLERSIMPL_H