nghttpx: Use raw pointer for apis

This commit is contained in:
Tatsuhiro Tsujikawa 2017-03-15 23:33:07 +09:00
parent 12a4e7c3a2
commit b21779e685
1 changed files with 18 additions and 13 deletions

View File

@ -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;
}