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,7 +35,8 @@ namespace shrpx {
namespace { namespace {
// List of API endpoints // List of API endpoints
const APIEndpoint apis[] = { const std::array<APIEndpoint, 2> &apis() {
static const auto apis = new std::array<APIEndpoint, 2>{{
APIEndpoint{ APIEndpoint{
StringRef::from_lit("/api/v1beta1/backendconfig"), true, StringRef::from_lit("/api/v1beta1/backendconfig"), true,
(1 << API_METHOD_POST) | (1 << API_METHOD_PUT), (1 << API_METHOD_POST) | (1 << API_METHOD_PUT),
@ -43,9 +44,13 @@ const APIEndpoint apis[] = {
}, },
APIEndpoint{ APIEndpoint{
StringRef::from_lit("/api/v1beta1/configrevision"), true, StringRef::from_lit("/api/v1beta1/configrevision"), true,
(1 << API_METHOD_GET), &APIDownstreamConnection::handle_configrevision, (1 << API_METHOD_GET),
&APIDownstreamConnection::handle_configrevision,
}, },
}; }};
return *apis;
}
} // namespace } // namespace
namespace { namespace {
@ -160,7 +165,7 @@ const APIEndpoint *lookup_api(const StringRef &path) {
switch (path[25]) { switch (path[25]) {
case 'g': case 'g':
if (util::streq_l("/api/v1beta1/backendconfi", std::begin(path), 25)) { if (util::streq_l("/api/v1beta1/backendconfi", std::begin(path), 25)) {
return &apis[0]; return &apis()[0];
} }
break; break;
} }
@ -169,7 +174,7 @@ const APIEndpoint *lookup_api(const StringRef &path) {
switch (path[26]) { switch (path[26]) {
case 'n': case 'n':
if (util::streq_l("/api/v1beta1/configrevisio", std::begin(path), 26)) { if (util::streq_l("/api/v1beta1/configrevisio", std::begin(path), 26)) {
return &apis[1]; return &apis()[1];
} }
break; break;
} }