3#include "Import/WebFrameworkCore.h"
5#include "FileManager.h"
7#include "BaseStatelessExecutor.h"
8#include "DynamicPages/WebFrameworkDynamicPages.h"
9#include "WebNetwork/Interfaces/IStaticFile.h"
10#include "WebNetwork/Interfaces/IDynamicFile.h"
24 internalServerError500,
29 const std::filesystem::path defaultAssets;
30 const std::filesystem::path assets;
32 std::array<std::string, HTMLErrors::HTMLErrorsSize> HTMLErrorsData;
33 file_manager::FileManager& fileManager;
39 void loadHTMLErrorsData();
41 void readFile(std::string& result, std::unique_ptr<file_manager::ReadFileHandle>&& handle);
44 ResourceExecutor(
const json::JSONParser& configuration,
const std::filesystem::path& assets, uint64_t cachingSize,
const std::filesystem::path& pathToTemplates);
58 void sendStaticFile(
const std::string& filePath,
HTTPResponse& response,
bool isBinary =
true,
const std::string& fileName =
"")
override;
66 void sendDynamicFile(
const std::string& filePath,
HTTPResponse& response,
const std::unordered_map<std::string, std::string>& variables = {},
bool isBinary =
true,
const std::string& fileName =
"")
override;
71 void registerDynamicFunction(
const std::string& functionName, std::function<std::string(
const std::vector<std::string>&)>&& function)
override;
97 const std::filesystem::path& getPathToAssets()
const final override;
117 bool getIsCaching()
const;
Base class for executors with constant or static states.
Used for sending asset files.
void registerDynamicFunction(const std::string &functionName, std::function< std::string(const std::vector< std::string > &)> &&function) override
Add new function in .wfdp interpreter.
void sendDynamicFile(const std::string &filePath, HTTPResponse &response, const std::unordered_map< std::string, std::string > &variables={}, bool isBinary=true, const std::string &fileName="") override
Override from IDynamicFile interface.
void internalServerError(HTTPResponse &response, const std::exception *exception)
Send 500.html from WebFrameworkAssets.
void badRequestError(HTTPResponse &response, const std::exception *exception)
Send 400.html from WebFrameworkAssets.
void doPost(HTTPRequest &request, HTTPResponse &response) override
Send file via POST request.
void init(const utility::JSONSettingsParser::ExecutorSettings &settings) override
Create assets folder.
void notFoundError(HTTPResponse &response, const std::exception *exception)
Send 404.html from WebFrameworkAssets.
void doGet(HTTPRequest &request, HTTPResponse &response) override
Send file via GET request.
bool isDynamicFunctionRegistered(const std::string &functionName) override
Check if function is registered.
void sendStaticFile(const std::string &filePath, HTTPResponse &response, bool isBinary=true, const std::string &fileName="") override
Override from IStaticFile interface.
void unregisterDynamicFunction(const std::string &functionName) override
Remove function from .wfdp interpreter.