1*f4c99e70SEd Tanous #pragma once 2*f4c99e70SEd Tanous 3*f4c99e70SEd Tanous #include "utils/query_param.hpp" 4*f4c99e70SEd Tanous 5*f4c99e70SEd Tanous #include <bmcweb_config.h> 6*f4c99e70SEd Tanous 7*f4c99e70SEd Tanous namespace redfish 8*f4c99e70SEd Tanous { 9*f4c99e70SEd Tanous 10*f4c99e70SEd Tanous [[nodiscard]] inline bool setUpRedfishRoute(crow::App& app, 11*f4c99e70SEd Tanous const crow::Request& req, 12*f4c99e70SEd Tanous crow::Response& res) 13*f4c99e70SEd Tanous { 14*f4c99e70SEd Tanous // If query parameters aren't enabled, do nothing. 15*f4c99e70SEd Tanous if constexpr (!bmcwebInsecureEnableQueryParams) 16*f4c99e70SEd Tanous { 17*f4c99e70SEd Tanous return true; 18*f4c99e70SEd Tanous } 19*f4c99e70SEd Tanous std::optional<query_param::Query> queryOpt = 20*f4c99e70SEd Tanous query_param::parseParameters(req.urlView.params(), res); 21*f4c99e70SEd Tanous if (queryOpt == std::nullopt) 22*f4c99e70SEd Tanous { 23*f4c99e70SEd Tanous return false; 24*f4c99e70SEd Tanous } 25*f4c99e70SEd Tanous 26*f4c99e70SEd Tanous std::function<void(crow::Response&)> handler = 27*f4c99e70SEd Tanous res.releaseCompleteRequestHandler(); 28*f4c99e70SEd Tanous 29*f4c99e70SEd Tanous res.setCompleteRequestHandler( 30*f4c99e70SEd Tanous [&app, handler(std::move(handler)), 31*f4c99e70SEd Tanous query{*queryOpt}](crow::Response& res) mutable { 32*f4c99e70SEd Tanous processAllParams(app, query, res, handler); 33*f4c99e70SEd Tanous }); 34*f4c99e70SEd Tanous return true; 35*f4c99e70SEd Tanous } 36*f4c99e70SEd Tanous } // namespace redfish 37