Commit b21779e6 authored by Tatsuhiro Tsujikawa's avatar Tatsuhiro Tsujikawa

nghttpx: Use raw pointer for apis

parent 12a4e7c3
......@@ -35,17 +35,22 @@ namespace shrpx {
namespace {
// List of API endpoints
const APIEndpoint apis[] = {
APIEndpoint{
StringRef::from_lit("/api/v1beta1/backendconfig"), true,
(1 << API_METHOD_POST) | (1 << API_METHOD_PUT),
&APIDownstreamConnection::handle_backendconfig,
},
APIEndpoint{
StringRef::from_lit("/api/v1beta1/configrevision"), true,
(1 << API_METHOD_GET), &APIDownstreamConnection::handle_configrevision,
},
};
const std::array<APIEndpoint, 2> &apis() {
static const auto apis = new std::array<APIEndpoint, 2>{{
APIEndpoint{
StringRef::from_lit("/api/v1beta1/backendconfig"), true,
(1 << API_METHOD_POST) | (1 << API_METHOD_PUT),
&APIDownstreamConnection::handle_backendconfig,
},
APIEndpoint{
StringRef::from_lit("/api/v1beta1/configrevision"), true,
(1 << API_METHOD_GET),
&APIDownstreamConnection::handle_configrevision,
},
}};
return *apis;
}
} // namespace
namespace {
......@@ -160,7 +165,7 @@ const APIEndpoint *lookup_api(const StringRef &path) {
switch (path[25]) {
case 'g':
if (util::streq_l("/api/v1beta1/backendconfi", std::begin(path), 25)) {
return &apis[0];
return &apis()[0];
}
break;
}
......@@ -169,7 +174,7 @@ const APIEndpoint *lookup_api(const StringRef &path) {
switch (path[26]) {
case 'n':
if (util::streq_l("/api/v1beta1/configrevisio", std::begin(path), 26)) {
return &apis[1];
return &apis()[1];
}
break;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment