Merge pull request #169 from an-tao/dev

Modify containers of AOP
This commit is contained in:
An Tao 2019-06-05 09:50:48 +08:00 committed by GitHub
commit 5be16f1b89
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 49 additions and 46 deletions

View File

@ -29,9 +29,9 @@ static const char banner[] =
void version::handleCommand(std::vector<std::string> &parameters)
{
std::cout << banner << std::endl;
std::cout << "drogon ctl tools" << std::endl;
std::cout << "version:" << VERSION << std::endl;
std::cout << "git commit:" << VERSION_MD5 << std::endl;
std::cout << "compile config:" << compileFlags << " " << includeDirs
std::cout << "A utility for drogon" << std::endl;
std::cout << "Version:" << VERSION << std::endl;
std::cout << "Git commit:" << VERSION_MD5 << std::endl;
std::cout << "Compile config:" << compileFlags << " " << includeDirs
<< std::endl;
}

View File

@ -62,15 +62,15 @@ class CacheMap
public:
/// constructor
/**
* @param loop
* eventloop pointer
* @param tickInterval
* second
* @param wheelsNum
* number of wheels
* @param bucketsNumPerWheel
* buckets number per wheel
* The max delay of the CacheMap is about
* @param loop
* eventloop pointer
* @param tickInterval
* second
* @param wheelsNum
* number of wheels
* @param bucketsNumPerWheel
* buckets number per wheel
* The max delay of the CacheMap is about
* tickInterval*(bucketsNumPerWheel^wheelsNum) seconds.
*/
CacheMap(trantor::EventLoop *loop,

View File

@ -152,7 +152,7 @@ class HttpAppFrameworkImpl : public HttpAppFramework
AdviceCallback &&,
AdviceChainCallback &&)> &advice) override
{
_postRoutingAdvices.emplace_front(advice);
_postRoutingAdvices.emplace_back(advice);
}
virtual void registerPreHandlingAdvice(
const std::function<void(const HttpRequestPtr &,
@ -170,7 +170,7 @@ class HttpAppFrameworkImpl : public HttpAppFramework
virtual void registerPostRoutingAdvice(
const std::function<void(const HttpRequestPtr &)> &advice) override
{
_postRoutingObservers.emplace_front(advice);
_postRoutingObservers.emplace_back(advice);
}
virtual void registerPreHandlingAdvice(
const std::function<void(const HttpRequestPtr &)> &advice) override
@ -181,7 +181,7 @@ class HttpAppFrameworkImpl : public HttpAppFramework
const std::function<void(const HttpRequestPtr &,
const HttpResponsePtr &)> &advice) override
{
_postHandlingAdvices.emplace_front(advice);
_postHandlingAdvices.emplace_back(advice);
}
virtual void enableSession(const size_t timeout = 0) override
@ -453,21 +453,21 @@ class HttpAppFrameworkImpl : public HttpAppFramework
AdviceCallback &&,
AdviceChainCallback &&)>>
_preRoutingAdvices;
std::deque<std::function<void(const HttpRequestPtr &,
AdviceCallback &&,
AdviceChainCallback &&)>>
std::vector<std::function<void(const HttpRequestPtr &,
AdviceCallback &&,
AdviceChainCallback &&)>>
_postRoutingAdvices;
std::vector<std::function<void(const HttpRequestPtr &,
AdviceCallback &&,
AdviceChainCallback &&)>>
_preHandlingAdvices;
std::deque<
std::vector<
std::function<void(const HttpRequestPtr &, const HttpResponsePtr &)>>
_postHandlingAdvices;
std::vector<std::function<void(const HttpRequestPtr &)>>
_preRoutingObservers;
std::deque<std::function<void(const HttpRequestPtr &)>>
std::vector<std::function<void(const HttpRequestPtr &)>>
_postRoutingObservers;
std::vector<std::function<void(const HttpRequestPtr &)>>
_preHandlingObservers;

View File

@ -35,11 +35,11 @@ class HttpControllersRouter : public trantor::NonCopyable
public:
HttpControllersRouter(
StaticFileRouter &router,
const std::deque<std::function<void(const HttpRequestPtr &,
AdviceCallback &&,
AdviceChainCallback &&)>>
const std::vector<std::function<void(const HttpRequestPtr &,
AdviceCallback &&,
AdviceChainCallback &&)>>
&postRoutingAdvices,
const std::deque<std::function<void(const HttpRequestPtr &)>>
const std::vector<std::function<void(const HttpRequestPtr &)>>
&postRoutingObservers,
const std::vector<std::function<void(const HttpRequestPtr &,
AdviceCallback &&,
@ -47,8 +47,8 @@ class HttpControllersRouter : public trantor::NonCopyable
&preHandlingAdvices,
const std::vector<std::function<void(const HttpRequestPtr &)>>
&preHandlingObservers,
const std::deque<std::function<void(const HttpRequestPtr &,
const HttpResponsePtr &)>>
const std::vector<std::function<void(const HttpRequestPtr &,
const HttpResponsePtr &)>>
&postHandlingAdvices)
: _fileRouter(router),
_postRoutingAdvices(postRoutingAdvices),
@ -98,19 +98,19 @@ class HttpControllersRouter : public trantor::NonCopyable
std::mutex _ctrlMutex;
std::regex _ctrlRegex;
const std::deque<std::function<void(const HttpRequestPtr &,
AdviceCallback &&,
AdviceChainCallback &&)>>
const std::vector<std::function<void(const HttpRequestPtr &,
AdviceCallback &&,
AdviceChainCallback &&)>>
&_postRoutingAdvices;
const std::vector<std::function<void(const HttpRequestPtr &,
AdviceCallback &&,
AdviceChainCallback &&)>>
&_preHandlingAdvices;
const std::deque<std::function<void(const HttpRequestPtr &)>>
const std::vector<std::function<void(const HttpRequestPtr &)>>
&_postRoutingObservers;
const std::vector<std::function<void(const HttpRequestPtr &)>>
&_preHandlingObservers;
const std::deque<
const std::vector<
std::function<void(const HttpRequestPtr &, const HttpResponsePtr &)>>
&_postHandlingAdvices;

View File

@ -372,13 +372,16 @@ HttpRequestPtr HttpRequest::newHttpFormPostRequest()
HttpRequestPtr HttpRequest::newHttpJsonRequest(const Json::Value &data)
{
static std::once_flag once;
static Json::StreamWriterBuilder builder;
std::call_once(once, []() {
builder["commentStyle"] = "None";
builder["indentation"] = "";
});
auto req = std::make_shared<HttpRequestImpl>(nullptr);
req->setMethod(drogon::Get);
req->setVersion(drogon::HttpRequest::kHttp11);
req->_contentType = CT_APPLICATION_JSON;
Json::StreamWriterBuilder builder;
builder["commentStyle"] = "None";
builder["indentation"] = "";
req->setContent(writeString(builder, data));
return req;
}

View File

@ -35,11 +35,11 @@ class HttpSimpleControllersRouter : public trantor::NonCopyable
public:
HttpSimpleControllersRouter(
HttpControllersRouter &httpCtrlRouter,
const std::deque<std::function<void(const HttpRequestPtr &,
AdviceCallback &&,
AdviceChainCallback &&)>>
const std::vector<std::function<void(const HttpRequestPtr &,
AdviceCallback &&,
AdviceChainCallback &&)>>
&postRoutingAdvices,
const std::deque<std::function<void(const HttpRequestPtr &)>>
const std::vector<std::function<void(const HttpRequestPtr &)>>
&postRoutingObservers,
const std::vector<std::function<void(const HttpRequestPtr &,
AdviceCallback &&,
@ -47,8 +47,8 @@ class HttpSimpleControllersRouter : public trantor::NonCopyable
&preHandlingAdvices,
const std::vector<std::function<void(const HttpRequestPtr &)>>
&preHandlingObservers,
const std::deque<std::function<void(const HttpRequestPtr &,
const HttpResponsePtr &)>>
const std::vector<std::function<void(const HttpRequestPtr &,
const HttpResponsePtr &)>>
&postHandlingAdvices)
: _httpCtrlsRouter(httpCtrlRouter),
_postRoutingAdvices(postRoutingAdvices),
@ -74,20 +74,20 @@ class HttpSimpleControllersRouter : public trantor::NonCopyable
private:
HttpControllersRouter &_httpCtrlsRouter;
const std::deque<std::function<void(const HttpRequestPtr &,
AdviceCallback &&,
AdviceChainCallback &&)>>
const std::vector<std::function<void(const HttpRequestPtr &,
AdviceCallback &&,
AdviceChainCallback &&)>>
&_postRoutingAdvices;
const std::vector<std::function<void(const HttpRequestPtr &,
AdviceCallback &&,
AdviceChainCallback &&)>>
&_preHandlingAdvices;
const std::deque<std::function<void(const HttpRequestPtr &)>>
const std::vector<std::function<void(const HttpRequestPtr &)>>
&_postRoutingObservers;
const std::vector<std::function<void(const HttpRequestPtr &)>>
&_preHandlingObservers;
const std::deque<
const std::vector<
std::function<void(const HttpRequestPtr &, const HttpResponsePtr &)>>
&_postHandlingAdvices;
struct CtrlBinder