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
|
* @param resp is the object set to 404 response
|
||||||
* After calling this method, the resp object is returned
|
* After calling this method, the resp object is returned
|
||||||
* by the HttpResponse::newNotFoundResponse() method.
|
* 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
|
/// Get the plugin object registered in the framework
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -70,10 +70,13 @@ class HttpAppFrameworkImpl : public HttpAppFramework
|
||||||
const std::vector<internal::HttpConstraint> &filtersAndMethods =
|
const std::vector<internal::HttpConstraint> &filtersAndMethods =
|
||||||
std::vector<internal::HttpConstraint>{}) override;
|
std::vector<internal::HttpConstraint>{}) override;
|
||||||
|
|
||||||
virtual HttpAppFramework &setCustom404Page(
|
virtual HttpAppFramework &setCustom404Page(const HttpResponsePtr &resp,
|
||||||
const HttpResponsePtr &resp) override
|
bool set404) override
|
||||||
{
|
{
|
||||||
resp->setStatusCode(k404NotFound);
|
if (set404)
|
||||||
|
{
|
||||||
|
resp->setStatusCode(k404NotFound);
|
||||||
|
}
|
||||||
_custom404 = resp;
|
_custom404 = resp;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue