Remove middlewares
Middlewares, while kinda cool from an academic standpoint, make our
build times even worse than they already are. Given that we only really
use 1 real middleware today (token auth) and it needs to move into the
parser mode anyway (for security limiting buffer sizes), we might as well
use this as an opportunity to delete some code.
Some other things that happen:
1. Persistent data now moves out of the crow namespace
2. App is no longer a template
3. All request_routes implementations no longer become templates. This
should be a decent (unmeasured) win on compile times.
This commit was part of a commit previously called "various cleanups".
This separates ONLY the middleware deletion part of that.
Note, this also deletes about 400 lines of hard to understand code.
Change-Id: I4c19e25491a153a2aa2e4ef46fc797bcb5b3581a
Signed-off-by: Ed Tanous <ed@tanous.net>
diff --git a/http/http_server.h b/http/http_server.h
index 0e8a702..c87ddd4 100644
--- a/http/http_server.h
+++ b/http/http_server.h
@@ -27,44 +27,39 @@
using namespace boost;
using tcp = asio::ip::tcp;
-template <typename Handler, typename Adaptor = boost::asio::ip::tcp::socket,
- typename... Middlewares>
+template <typename Handler, typename Adaptor = boost::asio::ip::tcp::socket>
class Server
{
public:
Server(Handler* handler, std::unique_ptr<tcp::acceptor>&& acceptor,
std::shared_ptr<boost::asio::ssl::context> adaptor_ctx,
- std::tuple<Middlewares...>* middlewares = nullptr,
std::shared_ptr<boost::asio::io_context> io =
std::make_shared<boost::asio::io_context>()) :
ioService(std::move(io)),
acceptor(std::move(acceptor)),
signals(*ioService, SIGINT, SIGTERM, SIGHUP), tickTimer(*ioService),
- timer(*ioService), handler(handler), middlewares(middlewares),
- adaptorCtx(adaptor_ctx)
+ timer(*ioService), handler(handler), adaptorCtx(adaptor_ctx)
{}
Server(Handler* handler, const std::string& bindaddr, uint16_t port,
std::shared_ptr<boost::asio::ssl::context> adaptor_ctx,
- std::tuple<Middlewares...>* middlewares = nullptr,
std::shared_ptr<boost::asio::io_context> io =
std::make_shared<boost::asio::io_context>()) :
Server(handler,
std::make_unique<tcp::acceptor>(
*io, tcp::endpoint(boost::asio::ip::make_address(bindaddr),
port)),
- adaptor_ctx, middlewares, io)
+ adaptor_ctx, io)
{}
Server(Handler* handler, int existing_socket,
std::shared_ptr<boost::asio::ssl::context> adaptor_ctx,
- std::tuple<Middlewares...>* middlewares = nullptr,
std::shared_ptr<boost::asio::io_context> io =
std::make_shared<boost::asio::io_context>()) :
Server(handler,
std::make_unique<tcp::acceptor>(*io, boost::asio::ip::tcp::v6(),
existing_socket),
- adaptor_ctx, middlewares, io)
+ adaptor_ctx, io)
{}
void setTickFunction(std::chrono::milliseconds d, std::function<void()> f)
@@ -223,11 +218,9 @@
boost::asio::ip::tcp::socket>>::value)
{
adaptorTemp = Adaptor(*ioService, *adaptorCtx);
- auto p =
- std::make_shared<Connection<Adaptor, Handler, Middlewares...>>(
- *ioService, handler, serverName, middlewares,
- getCachedDateStr, timerQueue,
- std::move(adaptorTemp.value()));
+ auto p = std::make_shared<Connection<Adaptor, Handler>>(
+ *ioService, handler, serverName, getCachedDateStr, timerQueue,
+ std::move(adaptorTemp.value()));
acceptor->async_accept(p->socket().next_layer(),
[this, p](boost::system::error_code ec) {
@@ -243,11 +236,9 @@
else
{
adaptorTemp = Adaptor(*ioService);
- auto p =
- std::make_shared<Connection<Adaptor, Handler, Middlewares...>>(
- *ioService, handler, serverName, middlewares,
- getCachedDateStr, timerQueue,
- std::move(adaptorTemp.value()));
+ auto p = std::make_shared<Connection<Adaptor, Handler>>(
+ *ioService, handler, serverName, getCachedDateStr, timerQueue,
+ std::move(adaptorTemp.value()));
acceptor->async_accept(
p->socket(), [this, p](boost::system::error_code ec) {
@@ -279,8 +270,6 @@
std::function<void()> tickFunction;
std::function<void(const boost::system::error_code& ec)> timerHandler;
- std::tuple<Middlewares...>* middlewares;
-
#ifdef BMCWEB_ENABLE_SSL
bool useSsl{false};
#endif