Modify code style

This commit is contained in:
an-tao 2019-01-21 23:58:00 +08:00
parent 7eba454ac8
commit d5d90d2f6f
8 changed files with 26 additions and 23 deletions

View File

@ -14,7 +14,6 @@
#include "create_model.h"
#include "cmd.h"
#include <drogon/config.h>
#include <drogon/utils/Utilities.h>
#include <drogon/HttpViewData.h>

View File

@ -22,7 +22,6 @@
#include <drogon/CacheMap.h>
#include <drogon/Session.h>
#include <trantor/utils/AsyncFileLogger.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/wait.h>

View File

@ -18,8 +18,10 @@
#include "HttpAppFrameworkImpl.h"
#include <stdlib.h>
#include <algorithm>
using namespace drogon;
using namespace std::placeholders;
HttpClientImpl::HttpClientImpl(trantor::EventLoop *loop,
const trantor::InetAddress &addr,
bool useSSL)
@ -28,6 +30,7 @@ HttpClientImpl::HttpClientImpl(trantor::EventLoop *loop,
_useSSL(useSSL)
{
}
HttpClientImpl::HttpClientImpl(trantor::EventLoop *loop,
const std::string &hostString)
: _loop(loop)
@ -83,16 +86,19 @@ HttpClientImpl::HttpClientImpl(trantor::EventLoop *loop,
}
LOG_TRACE << "userSSL=" << _useSSL << " domain=" << _domain;
}
HttpClientImpl::~HttpClientImpl()
{
LOG_TRACE << "Deconstruction HttpClient";
}
void HttpClientImpl::sendRequest(const drogon::HttpRequestPtr &req, const drogon::HttpReqCallback &callback)
{
_loop->runInLoop([=]() {
sendRequestInLoop(req, callback);
});
}
void HttpClientImpl::sendRequestInLoop(const drogon::HttpRequestPtr &req,
const drogon::HttpReqCallback &callback)
{
@ -105,7 +111,7 @@ void HttpClientImpl::sendRequestInLoop(const drogon::HttpRequestPtr &req,
_server.portNetEndian() != 0)
{
//dns
//TODO:timeout should be set by user
//TODO: timeout should be set by user
if (InetAddress::resolve(_domain, &_server) == false)
{
callback(ReqResult::BadServerAddress,

View File

@ -116,7 +116,6 @@ void HttpControllersRouter::addHttpPath(const std::string &path,
}
}
}
struct HttpControllerRouterItem router;
router.pathParameterPattern = pathParameterPattern;
if (validMethods.size() > 0)
@ -142,7 +141,7 @@ void HttpControllersRouter::route(const HttpRequestImplPtr &req,
bool needSetJsessionid,
std::string &&sessionId)
{
//find http controller
//Find http controller
if (_ctrlRegex.mark_count() > 0)
{
std::smatch result;
@ -168,7 +167,6 @@ void HttpControllersRouter::route(const HttpRequestImplPtr &req,
callback(res);
return;
}
auto &filters = binder->filtersName;
if (!filters.empty())
{
@ -234,7 +232,6 @@ void HttpControllersRouter::doControllerHandler(const CtrlBinderPtr &ctrlBinderP
}
return;
}
std::vector<std::string> params(ctrlBinderPtr->parameterPlaces.size());
std::smatch r;
if (std::regex_match(req->path(), r, routerItem._regex))
@ -269,7 +266,6 @@ void HttpControllersRouter::doControllerHandler(const CtrlBinderPtr &ctrlBinderP
LOG_TRACE << p;
paraList.push_back(std::move(p));
}
ctrlBinderPtr->binderPtr->handleHttpRequest(paraList, req, [=, callback = std::move(callback), sessionId = std::move(sessionId)](const HttpResponsePtr &resp) {
LOG_TRACE << "http resp:needSetJsessionid=" << needSetJsessionid << ";JSESSIONID=" << sessionId;
auto newResp = resp;

View File

@ -17,14 +17,17 @@
#include "HttpRequestParser.h"
#include "HttpResponseImpl.h"
#include <iostream>
using namespace trantor;
using namespace drogon;
HttpRequestParser::HttpRequestParser(const trantor::TcpConnectionPtr &connPtr)
: _state(kExpectRequestLine),
_request(new HttpRequestImpl),
_conn(connPtr)
{
}
bool HttpRequestParser::processRequestLine(const char *begin, const char *end)
{
bool succeed = false;
@ -122,7 +125,7 @@ bool HttpRequestParser::parseRequest(MsgBuffer *buf)
_request->getVersion() >= HttpRequest::kHttp11)
{
//rfc2616-8.2.3
//TODO:here we can add content-length limitation
//TODO: here we can add content-length limitation
auto connPtr = _conn.lock();
if (connPtr)
{
@ -209,6 +212,7 @@ void HttpRequestParser::pushRquestToPipeLine(const HttpRequestPtr &req)
_requestPipeLine.push_back(std::move(reqPair));
}
HttpRequestPtr HttpRequestParser::getFirstRequest() const
{
#ifndef NDEBUG
@ -224,6 +228,7 @@ HttpRequestPtr HttpRequestParser::getFirstRequest() const
}
return HttpRequestImplPtr();
}
HttpResponsePtr HttpRequestParser::getFirstResponse() const
{
#ifndef NDEBUG
@ -239,6 +244,7 @@ HttpResponsePtr HttpRequestParser::getFirstResponse() const
}
return HttpResponseImplPtr();
}
void HttpRequestParser::popFirstRequest()
{
#ifndef NDEBUG
@ -250,6 +256,7 @@ void HttpRequestParser::popFirstRequest()
#endif
_requestPipeLine.pop_front();
}
void HttpRequestParser::pushResponseToPipeLine(const HttpRequestPtr &req,
const HttpResponsePtr &resp)
{
@ -268,9 +275,4 @@ void HttpRequestParser::pushResponseToPipeLine(const HttpRequestPtr &req,
return;
}
}
}
// std::mutex &HttpRequestParser::getPipeLineMutex()
// {
// return *_pipeLineMutex;
// }
}

View File

@ -117,7 +117,7 @@ void SharedLibManager::managerLibs()
cmd.append(filename).append(" -o ").append(libPath);
LOG_TRACE << cmd;
auto r = system(cmd.c_str());
//TODO:handle r
//TODO: handle r
(void)(r);
auto srcFile = filename.substr(0, pos);
srcFile.append(".cc");

View File

@ -419,7 +419,7 @@ void MysqlConnection::outputError()
try
{
//TODO exception type
//TODO: exception type
throw SqlError(mysql_error(_mysqlPtr.get()),
_sql);
}

View File

@ -19,6 +19,7 @@
#include <stdio.h>
using namespace drogon::orm;
namespace drogon
{
namespace orm
@ -72,10 +73,7 @@ PgConnection::PgConnection(trantor::EventLoop *loop, const std::string &connInfo
_channel.enableReading();
_channel.enableWriting();
}
// int PgConnection::sock()
// {
// return PQsocket(_connPtr.get());
// }
void PgConnection::handleClosed()
{
_loop->assertInLoopThread();
@ -88,6 +86,7 @@ void PgConnection::handleClosed()
auto thisPtr = shared_from_this();
_closeCb(thisPtr);
}
void PgConnection::disconnect()
{
std::promise<int> pro;
@ -102,6 +101,7 @@ void PgConnection::disconnect()
});
f.get();
}
void PgConnection::pgPoll()
{
_loop->assertInLoopThread();
@ -146,6 +146,7 @@ void PgConnection::pgPoll()
break;
}
}
void PgConnection::execSql(std::string &&sql,
size_t paraNum,
std::vector<const char *> &&parameters,
@ -185,6 +186,7 @@ void PgConnection::execSql(std::string &&sql,
thisPtr->pgPoll();
});
}
void PgConnection::handleRead()
{
_loop->assertInLoopThread();
@ -216,7 +218,6 @@ void PgConnection::handleRead()
handleClosed();
return;
}
if (PQisBusy(_connPtr.get()))
{
//need read more data from socket;
@ -238,7 +239,7 @@ void PgConnection::handleRead()
{
try
{
//TODO exception type
//TODO: exception type
throw SqlError(PQerrorMessage(_connPtr.get()),
_sql);
}