Модификация страницы 404
По-умолчанию application::main() возвращает страницу 404, если не находит какой-либо иной путь для данного URL:
void application::main(std::string url) {
if(!dispatcher().dispatch(url)) {
response().make_error_response(http::response::not_found);
}
}
Для создания собственной страницы 404, необходимо переопределить стандартный application::main().
void myApplication::main(std::string url) {
if (!dispatcher().dispatch(url)) {
// Set the 404 status.
response().status(http::response::not_found);
response().out() << "Page not found";
}
}
Или воспользоваться своим собственным темплейтом:
void myApplication::main(std::string url) {
if (!dispatcher().dispatch(url)) {
// Set the 404 status.
response().status(http::response::not_found);
content::main c; // Your main template.
// c.content and c.title are defined in your template.
c.content = "Use the search box.";
c.title = "Page not found";
render("main", c);
}
}
