Adbase
Adinf C++ base library V2
|
#include <Server.hpp>
Public Member Functions | |
Server (Config httpConfig) | |
void | start (int threadNum=1) |
启动server More... | |
void | stop () |
void | registerLocation (const std::string &location, const OnRequest &process, void *data) |
向 server 中注册location More... | |
void | setLocationFallback (const OnLocationFallback &fallback) |
void | onRequestCallback (evhttp_request *req) |
void | threadFunc (int pipeFd) |
virtual | ~Server () |
Static Public Member Functions | |
static void | deleteThread (std::thread *t) |
Definition at line 36 of file Server.hpp.
adbase::http::Server::Server | ( | Config | httpConfig | ) |
Definition at line 48 of file Server.cpp.
References adbase::metrics::Metrics::buildTimers(), adbase::http::defaultFallback(), adbase::http::Config::getStatInterval(), adbase::http::Config::getTimeZone(), and LOG_DEBUG.
|
inlinevirtual |
Definition at line 48 of file Server.hpp.
|
static |
void adbase::http::Server::onRequestCallback | ( | evhttp_request * | req | ) |
Definition at line 65 of file Server.cpp.
References adbase::http::Response::getBodySize(), adbase::http::Response::getCode(), adbase::http::Request::getHeader(), adbase::http::Request::getLocation(), adbase::http::Request::getMethod(), adbase::http::Request::getRemoteAddress(), adbase::http::Request::getUri(), LOG_WARN, adbase::http::Request::METHOD_GET, adbase::http::Response::sendReply(), adbase::metrics::Timers::setTimer(), adbase::metrics::Timer::start(), and adbase::metrics::Timer::stop().
Referenced by adbase::http::httpServerOnRequestProxy().
void adbase::http::Server::registerLocation | ( | const std::string & | location, |
const OnRequest & | process, | ||
void * | data | ||
) |
向 server 中注册location
Definition at line 238 of file Server.cpp.
References LOG_DEBUG, LOG_INFO, and adbase::trim().
void adbase::http::Server::setLocationFallback | ( | const OnLocationFallback & | fallback | ) |
Definition at line 254 of file Server.cpp.
References adbase::AsyncLogging::append(), adbase::http::Config::getLogFormat(), adbase::Timestamp::kMicroSecondsPerSecond, adbase::Timestamp::microSecondsSinceEpoch(), adbase::Timestamp::now(), adbase::replace(), adbase::TimeZone::toLocalTime(), and adbase::TimeZone::valid().
void adbase::http::Server::start | ( | int | threadNum = 1 | ) |
启动server
Definition at line 181 of file Server.cpp.
References deleteThread(), adbase::http::Config::getLogDir(), adbase::http::Config::getLogRollSize(), adbase::http::Config::getServerName(), LOG_DEBUG, LOG_FATAL, adbase::AsyncLogging::start(), and threadFunc().
void adbase::http::Server::stop | ( | ) |
Definition at line 208 of file Server.cpp.
References LOG_ERROR.
void adbase::http::Server::threadFunc | ( | int | pipeFd | ) |
Definition at line 112 of file Server.cpp.
References adbase::http::Config::getBindAddress(), adbase::http::Config::getBindPort(), adbase::http::httpServerOnRequestProxy(), LOG_DEBUG, LOG_ERROR, LOG_FATAL, LOG_TRACE, and adbase::http::detail::pipeHandler().
Referenced by start().