Modify the Attributes interface of the HttpRequest class (#389)

This commit is contained in:
An Tao 2020-03-15 16:11:40 +08:00 committed by GitHub
parent 2401c6a88a
commit 6c850ea886
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 11 additions and 11 deletions

View File

@ -22,8 +22,8 @@
namespace drogon
{
/**
* @brief This class represents a attribute stored in the request context.
* One can get or set any type of data to a attribute object.
* @brief This class represents the attributes stored in the HTTP request.
* One can add/get any type of data to/from an Attributes object.
*/
class Attributes
{
@ -118,9 +118,7 @@ class Attributes
/**
* @brief Constructor, usually called by the framework
*/
Attributes()
{
}
Attributes() = default;
private:
using AttributesMap = std::map<std::string, any>;

View File

@ -229,11 +229,13 @@ class HttpRequest
return session();
}
/// Get the attributes store to which the request belongs.
virtual AttributesPtr attributes() const = 0;
/// Get the attributes store, users can add/get any type of data to/from
/// this store
virtual const AttributesPtr &attributes() const = 0;
/// Get the attributes store to which the request belongs.
AttributesPtr getAttributes() const
/// Get the attributes store, users can add/get any type of data to/from
/// this store
const AttributesPtr &getAttributes() const
{
return attributes();
}

View File

@ -352,7 +352,7 @@ class HttpRequestImpl : public HttpRequest
sessionPtr_ = session;
}
virtual AttributesPtr attributes() const override
virtual const AttributesPtr &attributes() const override
{
if (!attributesPtr_)
{

@ -1 +1 @@
Subproject commit 312a91e3e9cffa0ce24b4a87b674c64c6470ee96
Subproject commit ec56d4748d0e29f2369b6d1e9e2b8a4c7bed8892