aboutsummaryrefslogtreecommitdiffstats
path: root/include/crow.h
diff options
context:
space:
mode:
authorGino Maisto <luigi.maisto@gmail.com>2016-03-14 19:43:45 +0100
committerGino Maisto <luigi.maisto@gmail.com>2016-03-14 19:43:45 +0100
commite5d73b4c5303ae8a8a3fe027146f1dd35f9166f4 (patch)
treeb4d493373580ed7a71b4bdb8454e16f6fe0b44f3 /include/crow.h
parent206ecc77601725f3b3a34f28c58b00b835177148 (diff)
downloadcrow-e5d73b4c5303ae8a8a3fe027146f1dd35f9166f4.tar.gz
crow-e5d73b4c5303ae8a8a3fe027146f1dd35f9166f4.zip
Added support to bind to a specific interface
Diffstat (limited to 'include/crow.h')
-rw-r--r--include/crow.h19
1 files changed, 12 insertions, 7 deletions
diff --git a/include/crow.h b/include/crow.h
index ec4c0ee..31b96cb 100644
--- a/include/crow.h
+++ b/include/crow.h
@@ -9,7 +9,7 @@
#include <thread>
#include "settings.h"
-#include "logging.h"
+#include "logging.h"
#include "utility.h"
#include "routing.h"
#include "middleware_context.h"
@@ -64,6 +64,12 @@ namespace crow
return *this;
}
+ self_t& bindaddr(std::string bindaddr)
+ {
+ bindaddr_ = bindaddr;
+ return *this;
+ }
+
self_t& multithreaded()
{
return concurrency(std::thread::hardware_concurrency());
@@ -88,13 +94,13 @@ namespace crow
#ifdef CROW_ENABLE_SSL
if (use_ssl_)
{
- ssl_server_t server(this, port_, &middlewares_, concurrency_, &ssl_context_);
+ ssl_server_t server(this, bindaddr_, port_, &middlewares_, concurrency_, &ssl_context_);
server.run();
}
else
#endif
{
- server_t server(this, port_, &middlewares_, concurrency_, nullptr);
+ server_t server(this, bindaddr_, port_, &middlewares_, concurrency_, nullptr);
server.run();
}
}
@@ -151,7 +157,7 @@ namespace crow
// We can't call .ssl() member function unless CROW_ENABLE_SSL is defined.
static_assert(
// make static_assert dependent to T; always false
- std::is_base_of<T, void>::value,
+ std::is_base_of<T, void>::value,
"Define CROW_ENABLE_SSL to enable ssl support.");
return *this;
}
@@ -162,7 +168,7 @@ namespace crow
// We can't call .ssl() member function unless CROW_ENABLE_SSL is defined.
static_assert(
// make static_assert dependent to T; always false
- std::is_base_of<T, void>::value,
+ std::is_base_of<T, void>::value,
"Define CROW_ENABLE_SSL to enable ssl support.");
return *this;
}
@@ -187,7 +193,7 @@ namespace crow
private:
uint16_t port_ = 80;
uint16_t concurrency_ = 1;
-
+ std::string bindaddr_ = "0.0.0.0";
Router router_;
std::tuple<Middlewares...> middlewares_;
@@ -196,4 +202,3 @@ namespace crow
using App = Crow<Middlewares...>;
using SimpleApp = Crow<>;
};
-