Replaced std::strings with String in WebRoot.

This commit is contained in:
Relintai 2022-01-08 12:41:15 +01:00
parent 408984c99e
commit 90d62dbef7
2 changed files with 8 additions and 13 deletions

View File

@ -91,8 +91,8 @@ bool WebRoot::try_send_wwwroot_file(Request *request) {
return false;
}
void WebRoot::send_file(const std::string &path, Request *request) {
std::string fp = FileCache::get_singleton()->wwwroot + path;
void WebRoot::send_file(const String &path, Request *request) {
String fp = FileCache::get_singleton()->wwwroot + path;
request->send_file(fp);
}
@ -138,5 +138,5 @@ WebRoot::~WebRoot() {
_middlewares.clear();
}
std::string WebRoot::default_error_404_body = "<html><body>404 :(</body></html>";
std::string WebRoot::default_generic_error_body = "<html><body>Internal server error! :(</body></html>";
String WebRoot::default_error_404_body = "<html><body>404 :(</body></html>";
String WebRoot::default_generic_error_body = "<html><body>Internal server error! :(</body></html>";

View File

@ -5,7 +5,7 @@
#include "mutex"
#include <functional>
#include <map>
#include <string>
#include "core/string.h"
#include "web_router_node.h"
@ -14,25 +14,20 @@
class Request;
// FileCache -> set up, for this webroot, don't use singleton
// remove handler instances!
// Update the rest of the modules to the new systems
//remove std::strings
class WebRoot : public WebRouterNode {
RCPP_OBJECT(WebRoot, WebRouterNode);
public:
static std::string default_error_404_body;
static std::string default_generic_error_body;
static String default_error_404_body;
static String default_generic_error_body;
void handle_request_main(Request *request);
void handle_error_send_request(Request *request, const int error_code);
bool try_send_wwwroot_file(Request *request);
void send_file(const std::string &path, Request *request);
void send_file(const String &path, Request *request);
static void default_fallback_error_handler(Request *request, int error_code);
static void default_404_error_handler(Request *request, int error_code);