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 | f927347 | 2017-02-28 16:05:13 -0800 | [diff] [blame] | 25 | #include "token_authorization_middleware.hpp" |
Ed Tanous | 9992332 | 2017-03-03 14:21:24 -0800 | [diff] [blame^] | 26 | #include "webassets.hpp" |
Ed Tanous | f927347 | 2017-02-28 16:05:13 -0800 | [diff] [blame] | 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 | 9992332 | 2017-03-03 14:21:24 -0800 | [diff] [blame^] | 34 | int main(int argc, char** argv) { |
| 35 | auto worker = g3::LogWorker::createLogWorker(); |
| 36 | auto handle = worker->addDefaultLogger(argv[0], "/tmp/"); |
| 37 | g3::initializeLogging(worker.get()); |
| 38 | auto log_file_name = handle->call(&g3::FileSink::fileName); |
| 39 | auto sink_handle = worker->addSink(std::make_unique<crow::ColorCoutSink>(), &crow::ColorCoutSink::ReceiveLogMessage); |
Ed Tanous | 0fdddb1 | 2017-02-28 11:06:34 -0800 | [diff] [blame] | 40 | |
Ed Tanous | 9992332 | 2017-03-03 14:21:24 -0800 | [diff] [blame^] | 41 | LOG(DEBUG) << "Logging to " << log_file_name.get() << "\n"; |
Ed Tanous | 0fdddb1 | 2017-02-28 11:06:34 -0800 | [diff] [blame] | 42 | |
Ed Tanous | 9992332 | 2017-03-03 14:21:24 -0800 | [diff] [blame^] | 43 | std::string ssl_pem_file("server.pem"); |
| 44 | ensuressl::ensure_openssl_key_present_and_valid(ssl_pem_file); |
Ed Tanous | 0fdddb1 | 2017-02-28 11:06:34 -0800 | [diff] [blame] | 45 | |
Ed Tanous | 9992332 | 2017-03-03 14:21:24 -0800 | [diff] [blame^] | 46 | crow::App<crow::TokenAuthorizationMiddleware> app; |
Ed Tanous | 0fdddb1 | 2017-02-28 11:06:34 -0800 | [diff] [blame] | 47 | |
Ed Tanous | 9992332 | 2017-03-03 14:21:24 -0800 | [diff] [blame^] | 48 | crow::webassets::request_routes(app); |
Ed Tanous | 0fdddb1 | 2017-02-28 11:06:34 -0800 | [diff] [blame] | 49 | |
Ed Tanous | 9992332 | 2017-03-03 14:21:24 -0800 | [diff] [blame^] | 50 | crow::logger::setLogLevel(crow::LogLevel::DEBUG); |
Ed Tanous | 0fdddb1 | 2017-02-28 11:06:34 -0800 | [diff] [blame] | 51 | |
Ed Tanous | 9992332 | 2017-03-03 14:21:24 -0800 | [diff] [blame^] | 52 | app.port(18080).run(); |
Ed Tanous | 0fdddb1 | 2017-02-28 11:06:34 -0800 | [diff] [blame] | 53 | } |