Add overload function of newHttpResponse (#1646)

This commit is contained in:
fantasy-peak 2023-06-24 18:04:38 +08:00 committed by GitHub
parent 269399b701
commit 8e4474bf4c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 0 deletions

View File

@ -353,6 +353,9 @@ class DROGON_EXPORT HttpResponse
/// Create a normal response with a status code of 200ok and a content type
/// of text/html.
static HttpResponsePtr newHttpResponse();
/// Create a response with a status code and a content type
static HttpResponsePtr newHttpResponse(HttpStatusCode code,
ContentType type);
/// Create a response which returns a 404 page.
static HttpResponsePtr newNotFoundResponse();
/// Create a response which returns a json object. Its content type is set

View File

@ -71,6 +71,14 @@ HttpResponsePtr HttpResponse::newHttpResponse()
return res;
}
HttpResponsePtr HttpResponse::newHttpResponse(HttpStatusCode code,
ContentType type)
{
auto res = std::make_shared<HttpResponseImpl>(code, type);
doResponseCreateAdvices(res);
return res;
}
HttpResponsePtr HttpResponse::newHttpJsonResponse(const Json::Value &data)
{
auto res = std::make_shared<HttpResponseImpl>(k200OK, CT_APPLICATION_JSON);