mirror of
https://gitee.com/an-tao/drogon.git
synced 2024-12-04 04:38:14 +08:00
commit
5be16f1b89
@ -29,9 +29,9 @@ static const char banner[] =
|
||||
void version::handleCommand(std::vector<std::string> ¶meters)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
@ -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,
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user