#include <crow.h>

#include "server.hpp"

#define CREATE_ROUTE(route_path, html_path) \
    CROW_ROUTE(this->crowApp, route_path) \
    ([]() { \
        std::string page = crow::mustache::load(html_path).render_string(); \
        return page; \
    });

void Douwco::Server::setup() {
    CREATE_ROUTE("/", "home.html");
    CREATE_ROUTE("/about_me", "about_me.html");
    CREATE_ROUTE("/about_douwco", "about_douwco.html");
    CREATE_ROUTE("/games", "games.html");
}

void Douwco::Server::start() {
    crowApp
        .port(port)
        .multithreaded()
//        .ssl_file("dev_cert/certificate.pem","dev_cert/private.key")
        .run();
}