Ed Tanous | 0fdddb1 | 2017-02-28 11:06:34 -0800 | [diff] [blame] | 1 | #include "crow/ci_map.h" |
Ed Tanous | f927347 | 2017-02-28 16:05:13 -0800 | [diff] [blame] | 2 | #include "crow/http_parser_merged.h" |
| 3 | #include "crow/query_string.h" |
Ed Tanous | 0fdddb1 | 2017-02-28 11:06:34 -0800 | [diff] [blame] | 4 | //#include "crow/TinySHA1.hpp" |
Ed Tanous | f927347 | 2017-02-28 16:05:13 -0800 | [diff] [blame] | 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" |
Ed Tanous | 0fdddb1 | 2017-02-28 11:06:34 -0800 | [diff] [blame] | 19 | #include "crow/settings.h" |
| 20 | #include "crow/socket_adaptors.h" |
Ed Tanous | 0fdddb1 | 2017-02-28 11:06:34 -0800 | [diff] [blame] | 21 | #include "crow/utility.h" |
Ed Tanous | 0fdddb1 | 2017-02-28 11:06:34 -0800 | [diff] [blame] | 22 | #include "crow/websocket.h" |
Ed Tanous | 0fdddb1 | 2017-02-28 11:06:34 -0800 | [diff] [blame] | 23 | |
Ed Tanous | 5f34a9c | 2017-02-28 12:35:13 -0800 | [diff] [blame] | 24 | #include "color_cout_g3_sink.hpp" |
Ed Tanous | 904063f | 2017-03-02 16:48:24 -0800 | [diff] [blame^] | 25 | #include "webassets.hpp" |
Ed Tanous | f927347 | 2017-02-28 16:05:13 -0800 | [diff] [blame] | 26 | #include "token_authorization_middleware.hpp" |
| 27 | |
Ed Tanous | 0fdddb1 | 2017-02-28 11:06:34 -0800 | [diff] [blame] | 28 | #include <iostream> |
| 29 | #include <string> |
Ed Tanous | f927347 | 2017-02-28 16:05:13 -0800 | [diff] [blame] | 30 | #include "ssl_key_handler.hpp" |
Ed Tanous | 0fdddb1 | 2017-02-28 11:06:34 -0800 | [diff] [blame] | 31 | |
Ed Tanous | 904063f | 2017-03-02 16:48:24 -0800 | [diff] [blame^] | 32 | #include <webassets.hpp> |
| 33 | |
Ed Tanous | 0fdddb1 | 2017-02-28 11:06:34 -0800 | [diff] [blame] | 34 | int main(int argc, char** argv) |
| 35 | { |
Ed Tanous | f927347 | 2017-02-28 16:05:13 -0800 | [diff] [blame] | 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); |
Ed Tanous | 0fdddb1 | 2017-02-28 11:06:34 -0800 | [diff] [blame] | 42 | |
Ed Tanous | f927347 | 2017-02-28 16:05:13 -0800 | [diff] [blame] | 43 | LOG(DEBUG) << "Logging to " << log_file_name.get() << "\n"; |
Ed Tanous | 0fdddb1 | 2017-02-28 11:06:34 -0800 | [diff] [blame] | 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()); |
Ed Tanous | f927347 | 2017-02-28 16:05:13 -0800 | [diff] [blame] | 49 | crow::App<crow::TokenAuthorizationMiddleware> app; |
Ed Tanous | 0fdddb1 | 2017-02-28 11:06:34 -0800 | [diff] [blame] | 50 | |
| 51 | CROW_ROUTE(app, "/") |
Ed Tanous | f927347 | 2017-02-28 16:05:13 -0800 | [diff] [blame] | 52 | .name("hello")([] { |
| 53 | return "Hello World!"; |
Ed Tanous | 904063f | 2017-03-02 16:48:24 -0800 | [diff] [blame^] | 54 | }); |
Ed Tanous | 0fdddb1 | 2017-02-28 11:06:34 -0800 | [diff] [blame] | 55 | |
Ed Tanous | 904063f | 2017-03-02 16:48:24 -0800 | [diff] [blame^] | 56 | crow::webassets::request_routes(app); |
Ed Tanous | 0fdddb1 | 2017-02-28 11:06:34 -0800 | [diff] [blame] | 57 | |
Ed Tanous | 0fdddb1 | 2017-02-28 11:06:34 -0800 | [diff] [blame] | 58 | crow::logger::setLogLevel(crow::LogLevel::DEBUG); |
| 59 | |
Ed Tanous | 904063f | 2017-03-02 16:48:24 -0800 | [diff] [blame^] | 60 | app.port(18080).run(); |
Ed Tanous | 0fdddb1 | 2017-02-28 11:06:34 -0800 | [diff] [blame] | 61 | } |