#include "app.hpp"

#include "http_server.hpp"
#include "logging.hpp"

namespace crow
{

#ifdef BMCWEB_ENABLE_SSL
using ssl_context_t = boost::asio::ssl::context;
using ssl_socket_t = boost::beast::ssl_stream<boost::asio::ip::tcp::socket>;
using ssl_server_t = Server<App, ssl_socket_t>;
#else
using socket_t = boost::asio::ip::tcp::socket;
using server_t = Server<App, socket_t>;
#endif

#ifdef BMCWEB_ENABLE_SSL
std::unique_ptr<ssl_server_t> sslServer; // NOLINT
#else
std::unique_ptr<server_t> server; // NOLINT
#endif

void App::run()
{
#ifdef BMCWEB_ENABLE_SSL
    if (-1 == socketFd)
    {
        sslServer = std::make_unique<ssl_server_t>(this, bindaddrStr, portUint,
                                                   sslContext, io);
    }
    else
    {
        sslServer =
            std::make_unique<ssl_server_t>(this, socketFd, sslContext, io);
    }
    sslServer->run();

#else
    if (-1 == socketFd)
    {
        server = std::make_unique<server_t>(this, bindaddrStr, portUint,
                                            nullptr, io);
    }
    else
    {
        server = std::make_unique<server_t>(this, socketFd, nullptr, io);
    }
    server->run();
#endif
}

void App::debugPrint()

{
    BMCWEB_LOG_DEBUG << "Routing:";
    router.DebugPrint();
}

void App::handle(Request& req,
                 const std::shared_ptr<bmcweb::AsyncResp>& asyncResp)
{
    // allocate a requestStatsContext to track this request:
    asyncResp->requestStatsContext =
        std::make_shared<managedStore::RequestStatsContext>(
            managedStore::RequestStatsContext::queryURLKeyFor(req.method(),
                                                              req.url()));

    BMCWEB_LOG_INFO << "App: handle: "
                    << asyncResp->requestStatsContext->toJson();

    router.Handle(req, asyncResp);
}

} // namespace crow
