mirror of
https://github.com/Relintai/rcpp_framework.git
synced 2024-11-14 04:57:21 +01:00
The default 404 and generic errors html bodies are static members in Application, this makes them trivial to replace if they are static html.
This commit is contained in:
parent
4d6e1e5dd9
commit
cc8de9ed7f
@ -22,15 +22,13 @@ void Application::setup_middleware() {
|
||||
}
|
||||
|
||||
void Application::default_fallback_error_handler(int error_code, Request *request) {
|
||||
std::string body = "<html><body>Internal server error! :(</body></html>";
|
||||
request->response->setBody(body);
|
||||
request->response->setBody(default_generic_error_body);
|
||||
request->finalized = true;
|
||||
request->send();
|
||||
}
|
||||
|
||||
void Application::default_404_error_handler(int error_code, Request *request) {
|
||||
std::string body = "<html><body>404 :(</body></html>";
|
||||
request->response->setBody(body);
|
||||
request->response->setBody(default_error_404_body);
|
||||
request->finalized = true;
|
||||
request->send();
|
||||
}
|
||||
@ -144,3 +142,6 @@ std::function<void(int, Request *)> Application::default_error_handler_func = nu
|
||||
std::vector<std::function<void(Request *)> > Application::middlewares;
|
||||
|
||||
Application *Application::_instance = nullptr;
|
||||
|
||||
std::string Application::default_error_404_body = "<html><body>404 :(</body></html>";
|
||||
std::string Application::default_generic_error_body = "<html><body>Internal server error! :(</body></html>";
|
||||
|
@ -10,6 +10,9 @@ class Request;
|
||||
|
||||
class Application {
|
||||
public:
|
||||
static std::string default_error_404_body;
|
||||
static std::string default_generic_error_body;
|
||||
|
||||
static void handle_request(Request *request);
|
||||
static void send_error(int error_code, Request *request);
|
||||
static void send_file(const std::string &path, Request *request);
|
||||
|
Loading…
Reference in New Issue
Block a user