mirror of
https://gitee.com/an-tao/drogon.git
synced 2024-12-02 03:38:03 +08:00
Add option to disable setting the 404 status code (#277)
This commit is contained in:
parent
8f5c757ce2
commit
ddc41f7907
@ -108,8 +108,11 @@ class HttpAppFramework : public trantor::NonCopyable
|
||||
* @param resp is the object set to 404 response
|
||||
* After calling this method, the resp object is returned
|
||||
* by the HttpResponse::newNotFoundResponse() method.
|
||||
* @param set404 if true, the status code of the resp will
|
||||
* be set to 404 automatically
|
||||
*/
|
||||
virtual HttpAppFramework &setCustom404Page(const HttpResponsePtr &resp) = 0;
|
||||
virtual HttpAppFramework &setCustom404Page(const HttpResponsePtr &resp,
|
||||
bool set404 = true) = 0;
|
||||
|
||||
/// Get the plugin object registered in the framework
|
||||
/**
|
||||
|
@ -70,10 +70,13 @@ class HttpAppFrameworkImpl : public HttpAppFramework
|
||||
const std::vector<internal::HttpConstraint> &filtersAndMethods =
|
||||
std::vector<internal::HttpConstraint>{}) override;
|
||||
|
||||
virtual HttpAppFramework &setCustom404Page(
|
||||
const HttpResponsePtr &resp) override
|
||||
virtual HttpAppFramework &setCustom404Page(const HttpResponsePtr &resp,
|
||||
bool set404) override
|
||||
{
|
||||
resp->setStatusCode(k404NotFound);
|
||||
if (set404)
|
||||
{
|
||||
resp->setStatusCode(k404NotFound);
|
||||
}
|
||||
_custom404 = resp;
|
||||
return *this;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user