mirror of
https://github.com/Relintai/rcpp_framework.git
synced 2025-05-06 17:51:36 +02:00
Renamed DWebApplication to DrogonWebServer.
This commit is contained in:
parent
2133be9254
commit
f23b9f9748
@ -1,4 +1,4 @@
|
|||||||
#include "web_application.h"
|
#include "drogon_web_server.h"
|
||||||
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <string>
|
#include <string>
|
||||||
@ -27,32 +27,32 @@
|
|||||||
#include <io.h>
|
#include <io.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void DWebApplication::add_listener(const std::string &ip, uint16_t port, bool useSSL, const std::string &certFile, const std::string &keyFile, bool useOldTLS, const std::vector<std::pair<std::string, std::string> > &sslConfCmds) {
|
void DrogonWebServer::add_listener(const std::string &ip, uint16_t port, bool useSSL, const std::string &certFile, const std::string &keyFile, bool useOldTLS, const std::vector<std::pair<std::string, std::string> > &sslConfCmds) {
|
||||||
assert(!_running);
|
assert(!_running);
|
||||||
|
|
||||||
_listener_manager->addListener(ip, port, useSSL, certFile, keyFile, useOldTLS, sslConfCmds);
|
_listener_manager->addListener(ip, port, useSSL, certFile, keyFile, useOldTLS, sslConfCmds);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DWebApplication::set_thread_num(size_t thread_num) {
|
void DrogonWebServer::set_thread_num(size_t thread_num) {
|
||||||
if (_thread_num == 0) {
|
if (_thread_num == 0) {
|
||||||
_thread_num = std::thread::hardware_concurrency();
|
_thread_num = std::thread::hardware_concurrency();
|
||||||
}
|
}
|
||||||
|
|
||||||
_thread_num = _thread_num;
|
_thread_num = _thread_num;
|
||||||
}
|
}
|
||||||
size_t DWebApplication::get_thread_num() const {
|
size_t DrogonWebServer::get_thread_num() const {
|
||||||
return _thread_num;
|
return _thread_num;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DWebApplication::set_ssl_config_commands(const std::vector<std::pair<std::string, std::string> > &sslConfCmds) {
|
void DrogonWebServer::set_ssl_config_commands(const std::vector<std::pair<std::string, std::string> > &sslConfCmds) {
|
||||||
_ssl_conf_cmds = sslConfCmds;
|
_ssl_conf_cmds = sslConfCmds;
|
||||||
}
|
}
|
||||||
void DWebApplication::set_ssl_files(const std::string &certPath, const std::string &keyPath) {
|
void DrogonWebServer::set_ssl_files(const std::string &certPath, const std::string &keyPath) {
|
||||||
_ssl_cert_path = certPath;
|
_ssl_cert_path = certPath;
|
||||||
_ssl_key_path = keyPath;
|
_ssl_key_path = keyPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DWebApplication::run() {
|
void DrogonWebServer::run() {
|
||||||
if (!get_loop()->isInLoopThread()) {
|
if (!get_loop()->isInLoopThread()) {
|
||||||
get_loop()->moveToCurrentThread();
|
get_loop()->moveToCurrentThread();
|
||||||
}
|
}
|
||||||
@ -155,9 +155,9 @@ void DWebApplication::run() {
|
|||||||
|
|
||||||
// Create all listeners.
|
// Create all listeners.
|
||||||
auto ioLoops = _listener_manager->createListeners(get_loop(),
|
auto ioLoops = _listener_manager->createListeners(get_loop(),
|
||||||
std::bind(&DWebApplication::on_async_request, this, std::placeholders::_1, std::placeholders::_2),
|
std::bind(&DrogonWebServer::on_async_request, this, std::placeholders::_1, std::placeholders::_2),
|
||||||
std::bind(&DWebApplication::on_new_websock_request, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3),
|
std::bind(&DrogonWebServer::on_new_websock_request, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3),
|
||||||
std::bind(&DWebApplication::on_connection, this, std::placeholders::_1),
|
std::bind(&DrogonWebServer::on_connection, this, std::placeholders::_1),
|
||||||
_idle_connection_timeout, _ssl_cert_path, _ssl_key_path, _ssl_conf_cmds, _thread_num, _sync_advices, _pre_sending_advices);
|
_idle_connection_timeout, _ssl_cert_path, _ssl_key_path, _ssl_conf_cmds, _thread_num, _sync_advices, _pre_sending_advices);
|
||||||
|
|
||||||
assert(ioLoops.size() == _thread_num);
|
assert(ioLoops.size() == _thread_num);
|
||||||
@ -212,55 +212,55 @@ void DWebApplication::run() {
|
|||||||
get_loop()->loop();
|
get_loop()->loop();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DWebApplication::stop() {
|
void DrogonWebServer::stop() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void DWebApplication::enable_session(const size_t timeout) {
|
void DrogonWebServer::enable_session(const size_t timeout) {
|
||||||
_use_session = true;
|
_use_session = true;
|
||||||
_session_timeout = timeout;
|
_session_timeout = timeout;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DWebApplication::disable_session() {
|
void DrogonWebServer::disable_session() {
|
||||||
_use_session = false;
|
_use_session = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//todo think about it
|
//todo think about it
|
||||||
const std::string &DWebApplication::get_document_root() const {
|
const std::string &DrogonWebServer::get_document_root() const {
|
||||||
return _root_path;
|
return _root_path;
|
||||||
}
|
}
|
||||||
void DWebApplication::set_document_root(const std::string &rootPath) {
|
void DrogonWebServer::set_document_root(const std::string &rootPath) {
|
||||||
_root_path = rootPath;
|
_root_path = rootPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DWebApplication::set_static_file_headers(const std::vector<std::pair<std::string, std::string> > &headers) {
|
void DrogonWebServer::set_static_file_headers(const std::vector<std::pair<std::string, std::string> > &headers) {
|
||||||
// staticFileRouterPtr_->setStaticFileHeaders(headers);
|
// staticFileRouterPtr_->setStaticFileHeaders(headers);
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string &DWebApplication::get_upload_path() const {
|
const std::string &DrogonWebServer::get_upload_path() const {
|
||||||
return _upload_path;
|
return _upload_path;
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::shared_ptr<trantor::Resolver> &DWebApplication::get_resolver() const {
|
const std::shared_ptr<trantor::Resolver> &DrogonWebServer::get_resolver() const {
|
||||||
static std::shared_ptr<trantor::Resolver> resolver = trantor::Resolver::newResolver(get_loop());
|
static std::shared_ptr<trantor::Resolver> resolver = trantor::Resolver::newResolver(get_loop());
|
||||||
return resolver;
|
return resolver;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DWebApplication::set_upload_path(const std::string &uploadPath) {
|
void DrogonWebServer::set_upload_path(const std::string &uploadPath) {
|
||||||
_upload_path = uploadPath;
|
_upload_path = uploadPath;
|
||||||
}
|
}
|
||||||
void DWebApplication::set_file_types(const std::vector<std::string> &types) {
|
void DrogonWebServer::set_file_types(const std::vector<std::string> &types) {
|
||||||
//staticFileRouterPtr_->setFileTypes(types);
|
//staticFileRouterPtr_->setFileTypes(types);
|
||||||
//return *this;
|
//return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DWebApplication::set_max_connection_num(size_t maxConnections) {
|
void DrogonWebServer::set_max_connection_num(size_t maxConnections) {
|
||||||
_max_connection_num = maxConnections;
|
_max_connection_num = maxConnections;
|
||||||
}
|
}
|
||||||
void DWebApplication::set_max_connection_num_per_ip(size_t maxConnectionsPerIP) {
|
void DrogonWebServer::set_max_connection_num_per_ip(size_t maxConnectionsPerIP) {
|
||||||
_max_connection_num_per_ip = maxConnectionsPerIP;
|
_max_connection_num_per_ip = maxConnectionsPerIP;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DWebApplication::set_log_path(const std::string &logPath, const std::string &logfileBaseName, size_t logfileSize) {
|
void DrogonWebServer::set_log_path(const std::string &logPath, const std::string &logfileBaseName, size_t logfileSize) {
|
||||||
if (logPath.empty())
|
if (logPath.empty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -286,174 +286,174 @@ void DWebApplication::set_log_path(const std::string &logPath, const std::string
|
|||||||
_logfile_base_name = logfileBaseName;
|
_logfile_base_name = logfileBaseName;
|
||||||
_logfile_size = logfileSize;
|
_logfile_size = logfileSize;
|
||||||
}
|
}
|
||||||
void DWebApplication::set_log_level(trantor::Logger::LogLevel level) {
|
void DrogonWebServer::set_log_level(trantor::Logger::LogLevel level) {
|
||||||
trantor::Logger::setLogLevel(level);
|
trantor::Logger::setLogLevel(level);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DWebApplication::enable_sendfile(bool sendFile) {
|
void DrogonWebServer::enable_sendfile(bool sendFile) {
|
||||||
_use_sendfile = sendFile;
|
_use_sendfile = sendFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DWebApplication::enable_gzip(bool useGzip) {
|
void DrogonWebServer::enable_gzip(bool useGzip) {
|
||||||
_use_gzip = useGzip;
|
_use_gzip = useGzip;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DWebApplication::is_gzip_enabled() const {
|
bool DrogonWebServer::is_gzip_enabled() const {
|
||||||
return _use_gzip;
|
return _use_gzip;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DWebApplication::enable_brotli(bool useBrotli) {
|
void DrogonWebServer::enable_brotli(bool useBrotli) {
|
||||||
_use_brotli = useBrotli;
|
_use_brotli = useBrotli;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DWebApplication::is_brotli_enabled() const {
|
bool DrogonWebServer::is_brotli_enabled() const {
|
||||||
return _use_brotli;
|
return _use_brotli;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DWebApplication::set_static_files_cache_time(int cacheTime) {
|
void DrogonWebServer::set_static_files_cache_time(int cacheTime) {
|
||||||
//staticFileRouterPtr_->setStaticFilesCacheTime(cacheTime);
|
//staticFileRouterPtr_->setStaticFilesCacheTime(cacheTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
int DWebApplication::static_files_cache_time() const {
|
int DrogonWebServer::static_files_cache_time() const {
|
||||||
//return staticFileRouterPtr_->staticFilesCacheTime();
|
//return staticFileRouterPtr_->staticFilesCacheTime();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DWebApplication::set_idle_connection_timeout(size_t timeout) {
|
void DrogonWebServer::set_idle_connection_timeout(size_t timeout) {
|
||||||
_idle_connection_timeout = timeout;
|
_idle_connection_timeout = timeout;
|
||||||
}
|
}
|
||||||
void DWebApplication::set_keepalive_requests_number(const size_t number) {
|
void DrogonWebServer::set_keepalive_requests_number(const size_t number) {
|
||||||
_keepalive_requests_number = number;
|
_keepalive_requests_number = number;
|
||||||
}
|
}
|
||||||
void DWebApplication::set_pipelining_requests_number(const size_t number) {
|
void DrogonWebServer::set_pipelining_requests_number(const size_t number) {
|
||||||
_pipelining_requests_number = number;
|
_pipelining_requests_number = number;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DWebApplication::set_gzip_static(bool useGzipStatic) {
|
void DrogonWebServer::set_gzip_static(bool useGzipStatic) {
|
||||||
//staticFileRouterPtr_->setGzipStatic(useGzipStatic);
|
//staticFileRouterPtr_->setGzipStatic(useGzipStatic);
|
||||||
}
|
}
|
||||||
void DWebApplication::set_br_static(bool useGzipStatic) {
|
void DrogonWebServer::set_br_static(bool useGzipStatic) {
|
||||||
//staticFileRouterPtr_->setBrStatic(useGzipStatic);
|
//staticFileRouterPtr_->setBrStatic(useGzipStatic);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DWebApplication::set_client_max_body_size(size_t maxSize) {
|
void DrogonWebServer::set_client_max_body_size(size_t maxSize) {
|
||||||
_client_max_body_size = maxSize;
|
_client_max_body_size = maxSize;
|
||||||
}
|
}
|
||||||
void DWebApplication::set_client_max_memory_body_size(size_t maxSize) {
|
void DrogonWebServer::set_client_max_memory_body_size(size_t maxSize) {
|
||||||
_client_max_memory_body_size = maxSize;
|
_client_max_memory_body_size = maxSize;
|
||||||
}
|
}
|
||||||
void DWebApplication::set_client_max_web_socket_message_size(size_t maxSize) {
|
void DrogonWebServer::set_client_max_web_socket_message_size(size_t maxSize) {
|
||||||
_client_max_web_socket_message_size = maxSize;
|
_client_max_web_socket_message_size = maxSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DWebApplication::set_home_page(const std::string &homePageFile) {
|
void DrogonWebServer::set_home_page(const std::string &homePageFile) {
|
||||||
_home_page_file = homePageFile;
|
_home_page_file = homePageFile;
|
||||||
}
|
}
|
||||||
const std::string &DWebApplication::get_home_page() const {
|
const std::string &DrogonWebServer::get_home_page() const {
|
||||||
return _home_page_file;
|
return _home_page_file;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DWebApplication::set_implicit_page_enable(bool useImplicitPage) {
|
void DrogonWebServer::set_implicit_page_enable(bool useImplicitPage) {
|
||||||
//staticFileRouterPtr_->setImplicitPageEnable(useImplicitPage);
|
//staticFileRouterPtr_->setImplicitPageEnable(useImplicitPage);
|
||||||
}
|
}
|
||||||
bool DWebApplication::is_implicit_page_enabled() const {
|
bool DrogonWebServer::is_implicit_page_enabled() const {
|
||||||
//return staticFileRouterPtr_->isImplicitPageEnabled();
|
//return staticFileRouterPtr_->isImplicitPageEnabled();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
void DWebApplication::set_implicit_page(const std::string &implicitPageFile) {
|
void DrogonWebServer::set_implicit_page(const std::string &implicitPageFile) {
|
||||||
//staticFileRouterPtr_->setImplicitPage(implicitPageFile);
|
//staticFileRouterPtr_->setImplicitPage(implicitPageFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string &DWebApplication::get_implicit_page() const {
|
const std::string &DrogonWebServer::get_implicit_page() const {
|
||||||
//return staticFileRouterPtr_->getImplicitPage();
|
//return staticFileRouterPtr_->getImplicitPage();
|
||||||
static std::string s = "";
|
static std::string s = "";
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
size_t DWebApplication::get_client_max_body_size() const {
|
size_t DrogonWebServer::get_client_max_body_size() const {
|
||||||
return _client_max_body_size;
|
return _client_max_body_size;
|
||||||
}
|
}
|
||||||
size_t DWebApplication::get_client_max_memory_body_size() const {
|
size_t DrogonWebServer::get_client_max_memory_body_size() const {
|
||||||
return _client_max_memory_body_size;
|
return _client_max_memory_body_size;
|
||||||
}
|
}
|
||||||
size_t DWebApplication::get_client_max_web_socket_message_size() const {
|
size_t DrogonWebServer::get_client_max_web_socket_message_size() const {
|
||||||
return _client_max_web_socket_message_size;
|
return _client_max_web_socket_message_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t DWebApplication::keepalive_requests_number() const {
|
size_t DrogonWebServer::keepalive_requests_number() const {
|
||||||
return _keepalive_requests_number;
|
return _keepalive_requests_number;
|
||||||
}
|
}
|
||||||
size_t DWebApplication::pipelining_requests_number() const {
|
size_t DrogonWebServer::pipelining_requests_number() const {
|
||||||
return _pipelining_requests_number;
|
return _pipelining_requests_number;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DWebApplication::is_running() {
|
bool DrogonWebServer::is_running() {
|
||||||
return _running;
|
return _running;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DWebApplication::set_unicode_escaping_in_json(bool enable) {
|
void DrogonWebServer::set_unicode_escaping_in_json(bool enable) {
|
||||||
_using_unicode_escaping = enable;
|
_using_unicode_escaping = enable;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DWebApplication::is_unicode_escaping_used_in_json() const {
|
bool DrogonWebServer::is_unicode_escaping_used_in_json() const {
|
||||||
return _using_unicode_escaping;
|
return _using_unicode_escaping;
|
||||||
}
|
}
|
||||||
void DWebApplication::set_float_precision_in_json(unsigned int precision, const std::string &precisionType) {
|
void DrogonWebServer::set_float_precision_in_json(unsigned int precision, const std::string &precisionType) {
|
||||||
_float_precision_in_json = std::make_pair(precision, precisionType);
|
_float_precision_in_json = std::make_pair(precision, precisionType);
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::pair<unsigned int, std::string> &DWebApplication::get_float_precision_in_json() const {
|
const std::pair<unsigned int, std::string> &DrogonWebServer::get_float_precision_in_json() const {
|
||||||
return _float_precision_in_json;
|
return _float_precision_in_json;
|
||||||
}
|
}
|
||||||
|
|
||||||
trantor::EventLoop *DWebApplication::get_loop() const {
|
trantor::EventLoop *DrogonWebServer::get_loop() const {
|
||||||
return _loop;
|
return _loop;
|
||||||
}
|
}
|
||||||
trantor::EventLoop *DWebApplication::get_io_loop(size_t id) const {
|
trantor::EventLoop *DrogonWebServer::get_io_loop(size_t id) const {
|
||||||
assert(_listener_manager);
|
assert(_listener_manager);
|
||||||
|
|
||||||
return _listener_manager->getIOLoop(id);
|
return _listener_manager->getIOLoop(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DWebApplication::set_server_header_field(const std::string &server) {
|
void DrogonWebServer::set_server_header_field(const std::string &server) {
|
||||||
assert(!_running);
|
assert(!_running);
|
||||||
assert(server.find("\r\n") == std::string::npos);
|
assert(server.find("\r\n") == std::string::npos);
|
||||||
_server_header = "server: " + server + "\r\n";
|
_server_header = "server: " + server + "\r\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
void DWebApplication::enable_server_header(bool flag) {
|
void DrogonWebServer::enable_server_header(bool flag) {
|
||||||
_enable_server_header = flag;
|
_enable_server_header = flag;
|
||||||
}
|
}
|
||||||
void DWebApplication::enable_date_header(bool flag) {
|
void DrogonWebServer::enable_date_header(bool flag) {
|
||||||
_enable_date_header = flag;
|
_enable_date_header = flag;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DWebApplication::send_server_header() const {
|
bool DrogonWebServer::send_server_header() const {
|
||||||
return _enable_server_header;
|
return _enable_server_header;
|
||||||
}
|
}
|
||||||
bool DWebApplication::send_date_header() const {
|
bool DrogonWebServer::send_date_header() const {
|
||||||
return _enable_date_header;
|
return _enable_date_header;
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string &DWebApplication::get_server_header_string() const {
|
const std::string &DrogonWebServer::get_server_header_string() const {
|
||||||
return _server_header;
|
return _server_header;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<trantor::InetAddress> DWebApplication::get_listeners() const {
|
std::vector<trantor::InetAddress> DrogonWebServer::get_listeners() const {
|
||||||
return _listener_manager->getListeners();
|
return _listener_manager->getListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DWebApplication::use_sendfile() const {
|
bool DrogonWebServer::use_sendfile() const {
|
||||||
return _use_sendfile;
|
return _use_sendfile;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DWebApplication::support_ssl() const {
|
bool DrogonWebServer::support_ssl() const {
|
||||||
#ifdef OPENSSL_FOUND
|
#ifdef OPENSSL_FOUND
|
||||||
return true;
|
return true;
|
||||||
#endif
|
#endif
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t DWebApplication::get_current_thread_index() const {
|
size_t DrogonWebServer::get_current_thread_index() const {
|
||||||
trantor::EventLoop *loop = trantor::EventLoop::getEventLoopOfCurrentThread();
|
trantor::EventLoop *loop = trantor::EventLoop::getEventLoopOfCurrentThread();
|
||||||
|
|
||||||
if (loop) {
|
if (loop) {
|
||||||
@ -463,15 +463,15 @@ size_t DWebApplication::get_current_thread_index() const {
|
|||||||
return (std::numeric_limits<size_t>::max)();
|
return (std::numeric_limits<size_t>::max)();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DWebApplication::enable_reuse_port(bool enable) {
|
void DrogonWebServer::enable_reuse_port(bool enable) {
|
||||||
_reuse_port = enable;
|
_reuse_port = enable;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DWebApplication::reuse_port() const {
|
bool DrogonWebServer::reuse_port() const {
|
||||||
return _reuse_port;
|
return _reuse_port;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DWebApplication::on_async_request(const HttpRequestImplPtr &req, std::function<void(const HttpResponsePtr &)> &&callback) {
|
void DrogonWebServer::on_async_request(const HttpRequestImplPtr &req, std::function<void(const HttpResponsePtr &)> &&callback) {
|
||||||
|
|
||||||
LOG_TRACE << "new request:" << req->peerAddr().toIpPort() << "->" << req->localAddr().toIpPort();
|
LOG_TRACE << "new request:" << req->peerAddr().toIpPort() << "->" << req->localAddr().toIpPort();
|
||||||
LOG_TRACE << "Headers " << req->methodString() << " " << req->path();
|
LOG_TRACE << "Headers " << req->methodString() << " " << req->path();
|
||||||
@ -533,7 +533,7 @@ void DWebApplication::on_async_request(const HttpRequestImplPtr &req, std::funct
|
|||||||
handle_request(request);
|
handle_request(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DWebApplication::on_new_websock_request(const HttpRequestImplPtr &req, std::function<void(const HttpResponsePtr &)> &&callback, const WebSocketConnectionImplPtr &wsConnPtr) {
|
void DrogonWebServer::on_new_websock_request(const HttpRequestImplPtr &req, std::function<void(const HttpResponsePtr &)> &&callback, const WebSocketConnectionImplPtr &wsConnPtr) {
|
||||||
LOG_INFO << "on_new_websock_request";
|
LOG_INFO << "on_new_websock_request";
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -565,7 +565,7 @@ void DWebApplication::on_new_websock_request(const HttpRequestImplPtr &req, std:
|
|||||||
});
|
});
|
||||||
}*/
|
}*/
|
||||||
}
|
}
|
||||||
void DWebApplication::on_connection(const trantor::TcpConnectionPtr &conn) {
|
void DrogonWebServer::on_connection(const trantor::TcpConnectionPtr &conn) {
|
||||||
static std::mutex mtx;
|
static std::mutex mtx;
|
||||||
LOG_TRACE << "connect!!!" << _max_connection_num
|
LOG_TRACE << "connect!!!" << _max_connection_num
|
||||||
<< " num=" << _connection_num.load();
|
<< " num=" << _connection_num.load();
|
||||||
@ -622,7 +622,7 @@ void DWebApplication::on_connection(const trantor::TcpConnectionPtr &conn) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DWebApplication::find_session_for_request(const HttpRequestImplPtr &req) {
|
void DrogonWebServer::find_session_for_request(const HttpRequestImplPtr &req) {
|
||||||
if (_use_session) {
|
if (_use_session) {
|
||||||
std::string sessionId = req->getCookie("JSESSIONID");
|
std::string sessionId = req->getCookie("JSESSIONID");
|
||||||
bool needSetJsessionid = false;
|
bool needSetJsessionid = false;
|
||||||
@ -640,7 +640,7 @@ void DWebApplication::find_session_for_request(const HttpRequestImplPtr &req) {
|
|||||||
//void forward(const HttpRequestPtr &req, std::function<void(const HttpResponsePtr &)> &&callback,const std::string &hostString,double timeout);
|
//void forward(const HttpRequestPtr &req, std::function<void(const HttpResponsePtr &)> &&callback,const std::string &hostString,double timeout);
|
||||||
//void forward(const HttpRequestImplPtr &req,std::function<void(const HttpResponsePtr &)> &&callback,const std::string &hostString,double timeout = 0);
|
//void forward(const HttpRequestImplPtr &req,std::function<void(const HttpResponsePtr &)> &&callback,const std::string &hostString,double timeout = 0);
|
||||||
|
|
||||||
DWebApplication::DWebApplication() :
|
DrogonWebServer::DrogonWebServer() :
|
||||||
_listener_manager(new ListenerManager()), WebServer() {
|
_listener_manager(new ListenerManager()), WebServer() {
|
||||||
//staticFileRouterPtr_(new StaticFileRouter{}),
|
//staticFileRouterPtr_(new StaticFileRouter{}),
|
||||||
/*
|
/*
|
||||||
@ -670,5 +670,5 @@ DWebApplication::DWebApplication() :
|
|||||||
_upload_path = _root_path + "uploads";
|
_upload_path = _root_path + "uploads";
|
||||||
}
|
}
|
||||||
|
|
||||||
DWebApplication::~DWebApplication() {
|
DrogonWebServer::~DrogonWebServer() {
|
||||||
}
|
}
|
@ -1,5 +1,5 @@
|
|||||||
#ifndef DWEB_APPLICATION_H
|
#ifndef DROGON_WEB_SERVER_H
|
||||||
#define DWEB_APPLICATION_H
|
#define DROGON_WEB_SERVER_H
|
||||||
|
|
||||||
#include "core/http/web_server.h"
|
#include "core/http/web_server.h"
|
||||||
|
|
||||||
@ -30,8 +30,8 @@ using namespace drogon;
|
|||||||
|
|
||||||
class Request;
|
class Request;
|
||||||
|
|
||||||
class DWebApplication : public WebServer {
|
class DrogonWebServer : public WebServer {
|
||||||
RCPP_OBJECT(DWebApplication, WebServer);
|
RCPP_OBJECT(DrogonWebServer, WebServer);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void add_listener(const std::string &ip, uint16_t port,
|
void add_listener(const std::string &ip, uint16_t port,
|
||||||
@ -147,8 +147,8 @@ public:
|
|||||||
//void forward(const HttpRequestPtr &req, std::function<void(const HttpResponsePtr &)> &&callback,const std::string &hostString,double timeout);
|
//void forward(const HttpRequestPtr &req, std::function<void(const HttpResponsePtr &)> &&callback,const std::string &hostString,double timeout);
|
||||||
//void forward(const HttpRequestImplPtr &req,std::function<void(const HttpResponsePtr &)> &&callback,const std::string &hostString,double timeout = 0);
|
//void forward(const HttpRequestImplPtr &req,std::function<void(const HttpResponsePtr &)> &&callback,const std::string &hostString,double timeout = 0);
|
||||||
|
|
||||||
DWebApplication();
|
DrogonWebServer();
|
||||||
virtual ~DWebApplication();
|
virtual ~DrogonWebServer();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// We use a uuid string as session id;
|
// We use a uuid string as session id;
|
@ -1,6 +1,6 @@
|
|||||||
#include "request.h"
|
#include "request.h"
|
||||||
|
|
||||||
#include "web_application.h"
|
#include "drogon_web_server.h"
|
||||||
|
|
||||||
#include "core/http/cookie.h"
|
#include "core/http/cookie.h"
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
//using namespace drogon;
|
//using namespace drogon;
|
||||||
|
|
||||||
class DWebApplication;
|
class DrogonWebServer;
|
||||||
|
|
||||||
class DRequest : public Request {
|
class DRequest : public Request {
|
||||||
public:
|
public:
|
||||||
|
Loading…
Reference in New Issue
Block a user