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/app.h b/http/app.h
index ca871dc..dfd5304 100644
--- a/http/app.h
+++ b/http/app.h
@@ -3,7 +3,6 @@
 #include "http_request.h"
 #include "http_server.h"
 #include "logging.h"
-#include "middleware_context.h"
 #include "routing.h"
 #include "utility.h"
 
@@ -25,25 +24,24 @@
 #ifdef BMCWEB_ENABLE_SSL
 using ssl_context_t = boost::asio::ssl::context;
 #endif
-template <typename... Middlewares>
-class Crow
+class App
 {
   public:
-    using self_t = Crow;
+    using self_t = App;
 
 #ifdef BMCWEB_ENABLE_SSL
     using ssl_socket_t = boost::beast::ssl_stream<boost::asio::ip::tcp::socket>;
-    using ssl_server_t = Server<Crow, ssl_socket_t, Middlewares...>;
+    using ssl_server_t = Server<App, ssl_socket_t>;
 #else
     using socket_t = boost::asio::ip::tcp::socket;
-    using server_t = Server<Crow, socket_t, Middlewares...>;
+    using server_t = Server<App, socket_t>;
 #endif
 
-    explicit Crow(std::shared_ptr<boost::asio::io_context> ioIn =
-                      std::make_shared<boost::asio::io_context>()) :
+    explicit App(std::shared_ptr<boost::asio::io_context> ioIn =
+                     std::make_shared<boost::asio::io_context>()) :
         io(std::move(ioIn))
     {}
-    ~Crow()
+    ~App()
     {
         this->stop();
     }
@@ -100,12 +98,12 @@
         if (-1 == socketFd)
         {
             sslServer = std::move(std::make_unique<ssl_server_t>(
-                this, bindaddrStr, portUint, sslContext, &middlewares, io));
+                this, bindaddrStr, portUint, sslContext, io));
         }
         else
         {
-            sslServer = std::move(std::make_unique<ssl_server_t>(
-                this, socketFd, sslContext, &middlewares, io));
+            sslServer = std::move(
+                std::make_unique<ssl_server_t>(this, socketFd, sslContext, io));
         }
         sslServer->setTickFunction(tickInterval, tickFunction);
         sslServer->run();
@@ -115,12 +113,12 @@
         if (-1 == socketFd)
         {
             server = std::move(std::make_unique<server_t>(
-                this, bindaddrStr, portUint, nullptr, &middlewares, io));
+                this, bindaddrStr, portUint, nullptr, io));
         }
         else
         {
-            server = std::move(std::make_unique<server_t>(
-                this, socketFd, nullptr, &middlewares, io));
+            server = std::move(
+                std::make_unique<server_t>(this, socketFd, nullptr, io));
         }
         server->setTickFunction(tickInterval, tickFunction);
         server->run();
@@ -216,23 +214,6 @@
     }
 #endif
 
-    // middleware
-    using context_t = detail::Context<Middlewares...>;
-    template <typename T>
-    typename T::Context& getContext(const Request& req)
-    {
-        static_assert(black_magic::Contains<T, Middlewares...>::value,
-                      "App doesn't have the specified middleware type.");
-        auto& ctx = *reinterpret_cast<context_t*>(req.middlewareContext);
-        return ctx.template get<T>();
-    }
-
-    template <typename T>
-    T& getMiddleware()
-    {
-        return utility::getElementByType<T, Middlewares...>(middlewares);
-    }
-
     template <typename Duration, typename Func>
     self_t& tick(Duration d, Func f)
     {
@@ -255,15 +236,11 @@
     std::chrono::milliseconds tickInterval{};
     std::function<void()> tickFunction;
 
-    std::tuple<Middlewares...> middlewares;
-
 #ifdef BMCWEB_ENABLE_SSL
     std::unique_ptr<ssl_server_t> sslServer;
 #else
     std::unique_ptr<server_t> server;
 #endif
 };
-template <typename... Middlewares>
-using App = Crow<Middlewares...>;
-using SimpleApp = Crow<>;
 } // namespace crow
+using App = crow::App;