diff --git a/lib/inc/drogon/HttpResponse.h b/lib/inc/drogon/HttpResponse.h index 4e203cc7..fec8b3bb 100644 --- a/lib/inc/drogon/HttpResponse.h +++ b/lib/inc/drogon/HttpResponse.h @@ -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 diff --git a/lib/src/HttpResponseImpl.cc b/lib/src/HttpResponseImpl.cc index 8e1e7853..dcfb903c 100644 --- a/lib/src/HttpResponseImpl.cc +++ b/lib/src/HttpResponseImpl.cc @@ -71,6 +71,14 @@ HttpResponsePtr HttpResponse::newHttpResponse() return res; } +HttpResponsePtr HttpResponse::newHttpResponse(HttpStatusCode code, + ContentType type) +{ + auto res = std::make_shared(code, type); + doResponseCreateAdvices(res); + return res; +} + HttpResponsePtr HttpResponse::newHttpJsonResponse(const Json::Value &data) { auto res = std::make_shared(k200OK, CT_APPLICATION_JSON);