mirror of
https://github.com/CrowCpp/Crow.git
synced 2024-06-07 21:10:44 +00:00
Revert "defining CROW_ENABLE_SSL disables non SSL code"
This reverts commit 10f3238ffc
.
This commit is contained in:
parent
deff8222a4
commit
21c872e771
@ -52,10 +52,9 @@ namespace crow
|
||||
public:
|
||||
///This crow application
|
||||
using self_t = Crow;
|
||||
#ifndef CROW_ENABLE_SSL
|
||||
///The HTTP server
|
||||
using server_t = Server<Crow, SocketAdaptor, Middlewares...>;
|
||||
#else
|
||||
#ifdef CROW_ENABLE_SSL
|
||||
///An HTTP server that runs on SSL with an SSLAdaptor
|
||||
using ssl_server_t = Server<Crow, SSLAdaptor, Middlewares...>;
|
||||
#endif
|
||||
@ -255,22 +254,18 @@ namespace crow
|
||||
ssl_server_->run();
|
||||
}
|
||||
else
|
||||
{
|
||||
CROW_LOG_CRITICAL << "SSL context not defined, please define a certificate or SSL context.";
|
||||
}
|
||||
#else
|
||||
|
||||
server_ = std::move(std::unique_ptr<server_t>(new server_t(this, bindaddr_, port_, server_name_, &middlewares_, concurrency_, nullptr)));
|
||||
server_->set_tick_function(tick_interval_, tick_function_);
|
||||
server_->signal_clear();
|
||||
for (auto snum : signals_)
|
||||
{
|
||||
server_->signal_add(snum);
|
||||
}
|
||||
notify_server_start();
|
||||
server_->run();
|
||||
|
||||
#endif
|
||||
{
|
||||
server_ = std::move(std::unique_ptr<server_t>(new server_t(this, bindaddr_, port_, server_name_, &middlewares_, concurrency_, nullptr)));
|
||||
server_->set_tick_function(tick_interval_, tick_function_);
|
||||
server_->signal_clear();
|
||||
for (auto snum : signals_)
|
||||
{
|
||||
server_->signal_add(snum);
|
||||
}
|
||||
notify_server_start();
|
||||
server_->run();
|
||||
}
|
||||
}
|
||||
|
||||
///Stop the server
|
||||
@ -284,16 +279,14 @@ namespace crow
|
||||
}
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
CROW_LOG_CRITICAL << "SSL context not defined, please define a certificate or SSL context.";
|
||||
}
|
||||
#else
|
||||
|
||||
if (server_) {
|
||||
server_->stop();
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void debug_print()
|
||||
{
|
||||
CROW_LOG_DEBUG << "Routing:";
|
||||
@ -413,9 +406,9 @@ namespace crow
|
||||
|
||||
#ifdef CROW_ENABLE_SSL
|
||||
std::unique_ptr<ssl_server_t> ssl_server_;
|
||||
#else
|
||||
std::unique_ptr<server_t> server_;
|
||||
#endif
|
||||
std::unique_ptr<server_t> server_;
|
||||
|
||||
std::vector<int> signals_{SIGINT, SIGTERM};
|
||||
|
||||
bool server_started_{false};
|
||||
|
@ -23,7 +23,7 @@ namespace crow
|
||||
using namespace boost;
|
||||
using tcp = asio::ip::tcp;
|
||||
|
||||
template <typename Handler, typename Adaptor, typename ... Middlewares>
|
||||
template <typename Handler, typename Adaptor = SocketAdaptor, typename ... Middlewares>
|
||||
class Server
|
||||
{
|
||||
public:
|
||||
|
@ -49,13 +49,12 @@ namespace crow
|
||||
}
|
||||
|
||||
virtual void handle(const request&, response&, const routing_params&) = 0;
|
||||
#ifndef CROW_ENABLE_SSL
|
||||
virtual void handle_upgrade(const request&, response& res, SocketAdaptor&&)
|
||||
{
|
||||
res = response(404);
|
||||
res.end();
|
||||
}
|
||||
#else
|
||||
#ifdef CROW_ENABLE_SSL
|
||||
virtual void handle_upgrade(const request&, response& res, SSLAdaptor&&)
|
||||
{
|
||||
res = response(404);
|
||||
@ -400,12 +399,12 @@ namespace crow
|
||||
res = response(404);
|
||||
res.end();
|
||||
}
|
||||
#ifndef CROW_ENABLE_SSL
|
||||
|
||||
void handle_upgrade(const request& req, response&, SocketAdaptor&& adaptor) override
|
||||
{
|
||||
new crow::websocket::Connection<SocketAdaptor>(req, std::move(adaptor), open_handler_, message_handler_, close_handler_, error_handler_, accept_handler_);
|
||||
}
|
||||
#else
|
||||
#ifdef CROW_ENABLE_SSL
|
||||
void handle_upgrade(const request& req, response&, SSLAdaptor&& adaptor) override
|
||||
{
|
||||
new crow::websocket::Connection<SSLAdaptor>(req, std::move(adaptor), open_handler_, message_handler_, close_handler_, error_handler_, accept_handler_);
|
||||
|
@ -13,7 +13,7 @@ namespace crow
|
||||
{
|
||||
using namespace boost;
|
||||
using tcp = asio::ip::tcp;
|
||||
#ifndef CROW_ENABLE_SSL
|
||||
|
||||
///A wrapper for the asio::ip::tcp::socket and asio::ssl::stream
|
||||
struct SocketAdaptor
|
||||
{
|
||||
@ -83,7 +83,7 @@ namespace crow
|
||||
tcp::socket socket_;
|
||||
};
|
||||
|
||||
#else
|
||||
#ifdef CROW_ENABLE_SSL
|
||||
struct SSLAdaptor
|
||||
{
|
||||
using context = boost::asio::ssl::context;
|
||||
|
Loading…
Reference in New Issue
Block a user