1 #include "crow/ci_map.h" 2 #include "crow/http_parser_merged.h" 3 #include "crow/query_string.h" 4 //#include "crow/TinySHA1.hpp" 5 #include "crow/app.h" 6 #include "crow/common.h" 7 #include "crow/dumb_timer_queue.h" 8 #include "crow/http_connection.h" 9 #include "crow/http_request.h" 10 #include "crow/http_response.h" 11 #include "crow/http_server.h" 12 #include "crow/json.h" 13 #include "crow/logging.h" 14 #include "crow/middleware.h" 15 #include "crow/middleware_context.h" 16 #include "crow/mustache.h" 17 #include "crow/parser.h" 18 #include "crow/routing.h" 19 #include "crow/settings.h" 20 #include "crow/socket_adaptors.h" 21 #include "crow/utility.h" 22 #include "crow/websocket.h" 23 24 #include "color_cout_g3_sink.hpp" 25 #include "webassets.hpp" 26 #include "token_authorization_middleware.hpp" 27 28 #include <iostream> 29 #include <string> 30 #include "ssl_key_handler.hpp" 31 32 #include <webassets.hpp> 33 34 int main(int argc, char** argv) 35 { 36 auto worker = g3::LogWorker::createLogWorker(); 37 auto handle = worker->addDefaultLogger(argv[0], "/tmp/"); 38 g3::initializeLogging(worker.get()); 39 auto log_file_name = handle->call(&g3::FileSink::fileName); 40 auto sink_handle = worker->addSink(std::make_unique<crow::ColorCoutSink>(), 41 &crow::ColorCoutSink::ReceiveLogMessage); 42 43 LOG(DEBUG) << "Logging to " << log_file_name.get() << "\n"; 44 45 std::string ssl_pem_file("server.pem"); 46 ensuressl::ensure_openssl_key_present_and_valid(ssl_pem_file); 47 //auto handler2 = std::make_shared<ExampleLogHandler>(); 48 //crow::logger::setHandler(handler2.get()); 49 crow::App<crow::TokenAuthorizationMiddleware> app; 50 51 CROW_ROUTE(app, "/") 52 .name("hello")([] { 53 return "Hello World!"; 54 }); 55 56 crow::webassets::request_routes(app); 57 58 crow::logger::setLogLevel(crow::LogLevel::DEBUG); 59 60 app.port(18080).run(); 61 } 62