Deduplicate doAccept code

doAccept does essentially the same code in two ways.
boost::beast::lowest_layer is used elsewhere to deduplicate this code.
Use it here as well.

Tested:
curl -vvvv --insecure -u root:0penBmc "https://192.168.7.2:443/redfish/v1"
succeeds.

Signed-off-by: Ed Tanous <edtanous@google.com>
Change-Id: Idfb0cd8f62ffbc09d6e248c677c24ea1abcb7a5b
diff --git a/http/http_server.hpp b/http/http_server.hpp
index 4037789..bf4a091 100644
--- a/http/http_server.hpp
+++ b/http/http_server.hpp
@@ -164,45 +164,32 @@
 
     void doAccept()
     {
-        std::optional<Adaptor> adaptorTemp;
         boost::asio::steady_timer timer(*ioService);
+        std::shared_ptr<Connection<Adaptor, Handler>> connection;
         if constexpr (std::is_same<Adaptor,
                                    boost::beast::ssl_stream<
                                        boost::asio::ip::tcp::socket>>::value)
         {
-            adaptorTemp = Adaptor(*ioService, *adaptorCtx);
-            auto p = std::make_shared<Connection<Adaptor, Handler>>(
+            connection = std::make_shared<Connection<Adaptor, Handler>>(
                 handler, std::move(timer), getCachedDateStr,
-                std::move(adaptorTemp.value()));
-
-            acceptor->async_accept(p->socket().next_layer(),
-                                   [this, p](boost::system::error_code ec) {
-                                       if (!ec)
-                                       {
-                                           boost::asio::post(
-                                               *this->ioService,
-                                               [p] { p->start(); });
-                                       }
-                                       doAccept();
-                                   });
+                Adaptor(*ioService, *adaptorCtx));
         }
         else
         {
-            adaptorTemp = Adaptor(*ioService);
-            auto p = std::make_shared<Connection<Adaptor, Handler>>(
+            connection = std::make_shared<Connection<Adaptor, Handler>>(
                 handler, std::move(timer), getCachedDateStr,
-                std::move(adaptorTemp.value()));
-
-            acceptor->async_accept(
-                p->socket(), [this, p](boost::system::error_code ec) {
-                    if (!ec)
-                    {
-                        boost::asio::post(*this->ioService,
-                                          [p] { p->start(); });
-                    }
-                    doAccept();
-                });
+                Adaptor(*ioService));
         }
+        acceptor->async_accept(
+            boost::beast::get_lowest_layer(connection->socket()),
+            [this, connection](boost::system::error_code ec) {
+                if (!ec)
+                {
+                    boost::asio::post(*this->ioService,
+                                      [connection] { connection->start(); });
+                }
+                doAccept();
+            });
     }
 
   private: