blob: c2e336e86114ccd89d7750eb094291635d9d00d3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
// SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: Copyright OpenBMC Authors
#pragma once
#include "app.hpp"
#include "async_resp.hpp"
#include "http_request.hpp"
#include "redfish_oem_routing.hpp"
#include "sub_request.hpp"
#include "verb.hpp"
#include <memory>
namespace redfish
{
/*
* @brief Top level class installing and providing Redfish services
*/
class RedfishService
{
public:
/*
* @brief Redfish service constructor
*
* Loads Redfish configuration and installs schema resources
*
* @param[in] app Crow app on which Redfish will initialize
*/
explicit RedfishService(App& app);
// Temporary change to make redfish instance available in other places
// like query delegation.
static RedfishService& getInstance(App& app)
{
static RedfishService redfish(app);
return redfish;
}
void validate()
{
oemRouter.validate();
}
template <StringLiteral Rule>
auto& newRoute(HttpVerb method)
{
return oemRouter.newRule<Rule>(method);
}
void handleSubRoute(
const crow::Request& req,
const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) const
{
auto subReq = std::make_shared<SubRequest>(req);
if (!subReq->needHandling())
{
return;
}
oemRouter.handle(subReq, asyncResp);
}
OemRouter oemRouter;
};
template <StringLiteral Path>
auto& REDFISH_SUB_ROUTE(RedfishService& service, HttpVerb method)
{
return service.newRoute<Path>(method);
}
} // namespace redfish
|