mirror of
https://github.com/Laxilef/OTGateway.git
synced 2025-12-10 18:24:27 +05:00
feat: ability to use compressed files for StaticPage
This commit is contained in:
@@ -1,4 +1,7 @@
|
|||||||
#include <FS.h>
|
#include <FS.h>
|
||||||
|
#include <detail/mimetable.h>
|
||||||
|
|
||||||
|
using namespace mime;
|
||||||
|
|
||||||
class StaticPage : public RequestHandler {
|
class StaticPage : public RequestHandler {
|
||||||
public:
|
public:
|
||||||
@@ -61,6 +64,14 @@ public:
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if (!this->path.endsWith(FPSTR(mimeTable[gz].endsWith)) && !this->fs->exists(path)) {
|
||||||
|
String pathWithGz = this->path + FPSTR(mimeTable[gz].endsWith);
|
||||||
|
|
||||||
|
if (this->fs->exists(pathWithGz)) {
|
||||||
|
this->path += FPSTR(mimeTable[gz].endsWith);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
File file = this->fs->open(this->path, "r");
|
File file = this->fs->open(this->path, "r");
|
||||||
if (!file) {
|
if (!file) {
|
||||||
return false;
|
return false;
|
||||||
@@ -93,6 +104,6 @@ protected:
|
|||||||
BeforeSendCallback beforeSendCallback;
|
BeforeSendCallback beforeSendCallback;
|
||||||
String eTag;
|
String eTag;
|
||||||
const char* uri = nullptr;
|
const char* uri = nullptr;
|
||||||
const char* path = nullptr;
|
String path;
|
||||||
const char* cacheHeader = nullptr;
|
const char* cacheHeader = nullptr;
|
||||||
};
|
};
|
||||||
Reference in New Issue
Block a user