@@ -42,16 +42,20 @@ namespace crow // NOTE: Already documented in "crow/app.h"
42
42
class Server
43
43
{
44
44
public:
45
- Server (Handler* handler, std::string bindaddr, uint16_t port, std::string server_name = std::string(" Crow/" ) + VERSION, std::tuple<Middlewares...>* middlewares = nullptr , uint16_t concurrency = 1 , uint8_t timeout = 5 , typename Adaptor::context* adaptor_ctx = nullptr ):
46
- acceptor_ (io_context_, tcp::endpoint(asio::ip::make_address(bindaddr), port)),
45
+ Server (Handler* handler,
46
+ const tcp::endpoint& endpoint,
47
+ std::string server_name = std::string(" Crow/" ) + VERSION,
48
+ std::tuple<Middlewares...>* middlewares = nullptr ,
49
+ uint16_t concurrency = 1 ,
50
+ uint8_t timeout = 5 ,
51
+ typename Adaptor::context* adaptor_ctx = nullptr ):
52
+ acceptor_ (io_context_,endpoint),
47
53
signals_ (io_context_),
48
54
tick_timer_ (io_context_),
49
55
handler_ (handler),
50
56
concurrency_ (concurrency),
51
57
timeout_ (timeout),
52
58
server_name_ (server_name),
53
- port_ (port),
54
- bindaddr_ (bindaddr),
55
59
task_queue_length_pool_ (concurrency_ - 1 ),
56
60
middlewares_ (middlewares),
57
61
adaptor_ctx_ (adaptor_ctx)
@@ -150,11 +154,12 @@ namespace crow // NOTE: Already documented in "crow/app.h"
150
154
});
151
155
}
152
156
153
- port_ = acceptor_.local_endpoint ().port ();
154
- handler_->port (port_);
157
+ handler_->port (acceptor_.local_endpoint ().port ());
155
158
156
159
157
- CROW_LOG_INFO << server_name_ << " server is running at " << (handler_->ssl_used () ? " https://" : " http://" ) << bindaddr_ << " :" << acceptor_.local_endpoint ().port () << " using " << concurrency_ << " threads" ;
160
+ CROW_LOG_INFO << server_name_
161
+ << " server is running at " << (handler_->ssl_used () ? " https://" : " http://" )
162
+ << acceptor_.local_endpoint ().address () << " :" << acceptor_.local_endpoint ().port () << " using " << concurrency_ << " threads" ;
158
163
CROW_LOG_INFO << " Call `app.loglevel(crow::LogLevel::Warning)` to hide Info level logs." ;
159
164
160
165
signals_.async_wait (
@@ -192,7 +197,7 @@ namespace crow // NOTE: Already documented in "crow/app.h"
192
197
io_context_.stop (); // Close main io_service
193
198
}
194
199
195
- uint16_t port (){
200
+ uint16_t port () const {
196
201
return acceptor_.local_endpoint ().port ();
197
202
}
198
203
@@ -293,8 +298,6 @@ namespace crow // NOTE: Already documented in "crow/app.h"
293
298
uint16_t concurrency_{2 };
294
299
std::uint8_t timeout_;
295
300
std::string server_name_;
296
- uint16_t port_;
297
- std::string bindaddr_;
298
301
std::vector<std::atomic<unsigned int >> task_queue_length_pool_;
299
302
300
303
std::chrono::milliseconds tick_interval_;
0 commit comments