mirror of
https://github.com/CrowCpp/Crow.git
synced 2024-06-07 21:10:44 +00:00
Merge pull request #79 from makaveli/39-settable-server-name
Settable server name feature
This commit is contained in:
commit
0e7cee6ef1
@ -89,6 +89,7 @@ int main()
|
||||
//crow::logger::setHandler(std::make_shared<ExampleLogHandler>());
|
||||
|
||||
app.port(18080)
|
||||
.server_name("CrowCpp")
|
||||
.multithreaded()
|
||||
.run();
|
||||
}
|
||||
|
@ -96,6 +96,13 @@ namespace crow
|
||||
return *this;
|
||||
}
|
||||
|
||||
///Set the server name (default Crow/0.2)
|
||||
self_t& server_name(std::string server_name)
|
||||
{
|
||||
server_name_ = server_name;
|
||||
return *this;
|
||||
}
|
||||
|
||||
///The IP address that Crow will handle requests on (default is 0.0.0.0)
|
||||
self_t& bindaddr(std::string bindaddr)
|
||||
{
|
||||
@ -174,7 +181,7 @@ namespace crow
|
||||
#ifdef CROW_ENABLE_SSL
|
||||
if (use_ssl_)
|
||||
{
|
||||
ssl_server_ = std::move(std::unique_ptr<ssl_server_t>(new ssl_server_t(this, bindaddr_, port_, &middlewares_, concurrency_, &ssl_context_)));
|
||||
ssl_server_ = std::move(std::unique_ptr<ssl_server_t>(new ssl_server_t(this, bindaddr_, port_, server_name_, &middlewares_, concurrency_, &ssl_context_)));
|
||||
ssl_server_->set_tick_function(tick_interval_, tick_function_);
|
||||
notify_server_start();
|
||||
ssl_server_->run();
|
||||
@ -182,7 +189,7 @@ namespace crow
|
||||
else
|
||||
#endif
|
||||
{
|
||||
server_ = std::move(std::unique_ptr<server_t>(new server_t(this, bindaddr_, port_, &middlewares_, concurrency_, nullptr)));
|
||||
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_);
|
||||
notify_server_start();
|
||||
server_->run();
|
||||
@ -311,6 +318,7 @@ namespace crow
|
||||
private:
|
||||
uint16_t port_ = 80;
|
||||
uint16_t concurrency_ = 1;
|
||||
std::string server_name_ = "Crow/0.2";
|
||||
std::string bindaddr_ = "0.0.0.0";
|
||||
Router router_;
|
||||
|
||||
|
@ -26,12 +26,13 @@ namespace crow
|
||||
class Server
|
||||
{
|
||||
public:
|
||||
Server(Handler* handler, std::string bindaddr, uint16_t port, std::tuple<Middlewares...>* middlewares = nullptr, uint16_t concurrency = 1, typename Adaptor::context* adaptor_ctx = nullptr)
|
||||
Server(Handler* handler, std::string bindaddr, uint16_t port, std::string server_name = "Crow/0.2", std::tuple<Middlewares...>* middlewares = nullptr, uint16_t concurrency = 1, typename Adaptor::context* adaptor_ctx = nullptr)
|
||||
: acceptor_(io_service_, tcp::endpoint(boost::asio::ip::address::from_string(bindaddr), port)),
|
||||
signals_(io_service_, SIGINT, SIGTERM),
|
||||
tick_timer_(io_service_),
|
||||
handler_(handler),
|
||||
concurrency_(concurrency == 0 ? 1 : concurrency),
|
||||
server_name_(server_name),
|
||||
port_(port),
|
||||
bindaddr_(bindaddr),
|
||||
middlewares_(middlewares),
|
||||
@ -218,7 +219,7 @@ namespace crow
|
||||
|
||||
Handler* handler_;
|
||||
uint16_t concurrency_{1};
|
||||
std::string server_name_ = "Crow/0.2";
|
||||
std::string server_name_;
|
||||
uint16_t port_;
|
||||
std::string bindaddr_;
|
||||
unsigned int roundrobin_index_{};
|
||||
|
Loading…
Reference in New Issue
Block a user