Modify the method to generate the 404 page (#240)
This commit is contained in:
parent
1e83a5cc4e
commit
fff40952a3
|
@ -15,7 +15,12 @@
|
|||
*/
|
||||
|
||||
#include <drogon/DrTemplate.h>
|
||||
|
||||
namespace drogon
|
||||
{
|
||||
/**
|
||||
* @brief This class is used by the drogon to generate the 404 page. Users don't
|
||||
* use this class directly.
|
||||
*/
|
||||
class NotFound : public drogon::DrTemplate<NotFound>
|
||||
{
|
||||
public:
|
||||
|
@ -23,3 +28,4 @@ class NotFound : public drogon::DrTemplate<NotFound>
|
|||
virtual ~NotFound(){};
|
||||
virtual std::string genText(const drogon::HttpViewData &) override;
|
||||
};
|
||||
} // namespace drogon
|
||||
|
|
|
@ -78,8 +78,13 @@ HttpResponsePtr HttpResponse::newNotFoundResponse()
|
|||
std::call_once(once, []() {
|
||||
HttpViewData data;
|
||||
data.insert("version", getVersion());
|
||||
notFoundResp = HttpResponse::newHttpViewResponse("NotFound", data);
|
||||
notFoundResp =
|
||||
HttpResponse::newHttpViewResponse("drogon::NotFound", data);
|
||||
notFoundResp->setStatusCode(k404NotFound);
|
||||
notFoundResp->setExpiredTime(0);
|
||||
auto str = static_cast<HttpResponseImpl *>(notFoundResp.get())
|
||||
->renderToString();
|
||||
LOG_TRACE << *str;
|
||||
});
|
||||
return notFoundResp;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue