From 710adfcf07d73b00a9bb6f8bf977cdb0897fa4b8 Mon Sep 17 00:00:00 2001 From: Ed Tanous Date: Tue, 24 Oct 2017 17:04:52 -0700 Subject: Add the redfish static files to the build ...And delete the old webserver static files from the repo. Move $metadata to a static file, as that's really where it belongs. Change-Id: I2caeee7cd779b7c07cfc10cd693459105656671f --- include/redfish_v1.hpp | 264 ++----------------------------------------------- include/webassets.hpp | 8 ++ 2 files changed, 17 insertions(+), 255 deletions(-) (limited to 'include') diff --git a/include/redfish_v1.hpp b/include/redfish_v1.hpp index d13eb13..e106079 100644 --- a/include/redfish_v1.hpp +++ b/include/redfish_v1.hpp @@ -61,260 +61,6 @@ void request_routes(Crow& app) { res.end(); }); - CROW_ROUTE(app, "/redfish/v1/$metadata/") - .methods( - "GET"_method)([&](const crow::request& req, crow::response& res) { - const char* response_text = R"( - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - )"; - - res.body = response_text; - res.add_header("Content-Type", "application/xml"); - res.end(); - }); - CROW_ROUTE(app, "/redfish/v1/Chassis/") .methods("GET"_method)( [&](const crow::request& req, crow::response& res) { @@ -561,7 +307,15 @@ void request_routes(Crow& app) { const std::string& session) { auto& data_middleware = app.template get_middleware(); - auto session_it = data_middleware.auth_tokens.find(session); + // TODO(Ed) this is inefficient + auto session_it = data_middleware.auth_tokens.begin(); + while (session_it != data_middleware.auth_tokens.end()) { + if (session_it->second.unique_id == session) { + break; + } + session_it++; + } + if (session_it == data_middleware.auth_tokens.end()) { res.code = 404; res.end(); diff --git a/include/webassets.hpp b/include/webassets.hpp index 7845d71..3afa61f 100644 --- a/include/webassets.hpp +++ b/include/webassets.hpp @@ -78,6 +78,14 @@ void request_routes(Crow& app) { auto content_type_it = content_types.find(webpath.extension().c_str()); if (content_type_it != content_types.end()) { content_type = content_type_it->second; + } else { + if (webpath.string() == "$metadata"){ + content_type_it = content_types.find(".xml"); + // should always be true + if (content_type_it != content_types.end()) { + content_type = content_type_it->second; + } + } } app.route_dynamic(std::string(webpath.string()))( [is_gzip, absolute_path_str, content_type](const crow::request& req, -- cgit v1.2.3