WebFramework v3.0.12
Web framework for C++.
|
Used for sending asset files. More...
#include <ResourceExecutor.h>
Public Member Functions | |
ResourceExecutor (const json::JSONParser &configuration, const std::filesystem::path &assets, uint64_t cachingSize, const std::filesystem::path &pathToTemplates) | |
void | init (const utility::JSONSettingsParser::ExecutorSettings &settings) override |
Create assets folder. | |
void | sendStaticFile (const std::string &filePath, HTTPResponse &response, bool isBinary=true, const std::string &fileName="") override |
Override from IStaticFile interface. | |
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 | registerDynamicFunction (const std::string &functionName, std::function< std::string(const std::vector< std::string > &)> &&function) override |
Add new function in .wfdp interpreter. | |
void | unregisterDynamicFunction (const std::string &functionName) override |
Remove function from .wfdp interpreter. | |
bool | isDynamicFunctionRegistered (const std::string &functionName) override |
Check if function is registered. | |
void | doGet (HTTPRequest &request, HTTPResponse &response) override |
Send file via GET request. | |
void | doPost (HTTPRequest &request, HTTPResponse &response) override |
Send file via POST request. | |
const std::filesystem::path & | getPathToAssets () const final override |
void | notFoundError (HTTPResponse &response, const std::exception *exception) |
Send 404.html from WebFrameworkAssets. | |
void | badRequestError (HTTPResponse &response, const std::exception *exception) |
Send 400.html from WebFrameworkAssets. | |
void | internalServerError (HTTPResponse &response, const std::exception *exception) |
Send 500.html from WebFrameworkAssets. | |
bool | getIsCaching () const |
![]() | |
![]() | |
![]() | |
![]() | |
virtual executorType | getType () const final override |
Get executor type. | |
virtual void | destroy () final override |
Stateless executors can't call destroy method. | |
![]() | |
virtual void | doHead (HTTPRequest &request, HTTPResponse &response) |
Process HEAD request. | |
virtual void | doPut (HTTPRequest &request, HTTPResponse &response) |
Process PUT request. | |
virtual void | doDelete (HTTPRequest &request, HTTPResponse &response) |
Process DELETE request. | |
virtual void | doPatch (HTTPRequest &request, HTTPResponse &response) |
Process PATCH request. | |
virtual void | doOptions (HTTPRequest &request, HTTPResponse &response) |
Process OPTIONS request. | |
virtual void | doTrace (HTTPRequest &request, HTTPResponse &response) |
Process TRACE request. | |
virtual void | doConnect (HTTPRequest &request, HTTPResponse &response) |
Process CONNECT request. | |
Additional Inherited Members | |
![]() | |
enum class | executorType { none , stateful , stateless , heavyOperationStateful , heavyOperationStateless } |
Used for sending asset files.
Definition at line 17 of file ResourceExecutor.h.
framework::ResourceExecutor::ResourceExecutor | ( | const json::JSONParser & | configuration, |
const std::filesystem::path & | assets, | ||
uint64_t | cachingSize, | ||
const std::filesystem::path & | pathToTemplates ) |
Definition at line 54 of file ResourceExecutor.cpp.
void framework::ResourceExecutor::badRequestError | ( | HTTPResponse & | response, |
const std::exception * | exception ) |
Send 400.html from WebFrameworkAssets.
response | response with error file |
Definition at line 189 of file ResourceExecutor.cpp.
|
overridevirtual |
Send file via GET request.
request | file request |
response | response with asset file |
Reimplemented from framework::BaseExecutor.
Definition at line 154 of file ResourceExecutor.cpp.
|
overridevirtual |
Send file via POST request.
request | file request |
response | response with asset file |
Reimplemented from framework::BaseExecutor.
Definition at line 159 of file ResourceExecutor.cpp.
bool framework::ResourceExecutor::getIsCaching | ( | ) | const |
Definition at line 229 of file ResourceExecutor.cpp.
|
finaloverridevirtual |
Implements framework::interfaces::IFile.
Definition at line 164 of file ResourceExecutor.cpp.
|
overridevirtual |
Create assets folder.
settings | not used |
Reimplemented from framework::BaseExecutor.
Definition at line 68 of file ResourceExecutor.cpp.
void framework::ResourceExecutor::internalServerError | ( | HTTPResponse & | response, |
const std::exception * | exception ) |
Send 500.html from WebFrameworkAssets.
response | response with error file |
Definition at line 209 of file ResourceExecutor.cpp.
|
overridevirtual |
Check if function is registered.
functionName | Name of function |
Implements framework::interfaces::IDynamicFile.
Definition at line 149 of file ResourceExecutor.cpp.
void framework::ResourceExecutor::notFoundError | ( | HTTPResponse & | response, |
const std::exception * | exception ) |
Send 404.html from WebFrameworkAssets.
response | response with error file |
Definition at line 169 of file ResourceExecutor.cpp.
|
overridevirtual |
Add new function in .wfdp interpreter.
functionName | Name of new function |
function | Function implementation |
Implements framework::interfaces::IDynamicFile.
Definition at line 139 of file ResourceExecutor.cpp.
|
overridevirtual |
Override from IDynamicFile interface.
filePath | path to file from assets folder |
response | used for sending file |
file_manager::exceptions::FileDoesNotExistException |
Implements framework::interfaces::IDynamicFile.
Definition at line 110 of file ResourceExecutor.cpp.
|
overridevirtual |
Override from IStaticFile interface.
filePath | path to file from assets folder |
response | used for sending file |
file_manager::exceptions::FileDoesNotExistException |
Implements framework::interfaces::IStaticFile.
Definition at line 83 of file ResourceExecutor.cpp.
|
overridevirtual |
Remove function from .wfdp interpreter.
functionName | Name of function |
Implements framework::interfaces::IDynamicFile.
Definition at line 144 of file ResourceExecutor.cpp.