Skip to content

Commit

Permalink
Adaptive changes for HttpManager
Browse files Browse the repository at this point in the history
Relevant changes: eBay/IOManager#100
  • Loading branch information
yuwmao committed Aug 30, 2024
1 parent 4d999d4 commit 3ddcb39
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions src/lib/homestore_backend/hs_http_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,8 @@ HttpManager::HttpManager(HSHomeObject& ho) : ho_(ho) {
using namespace Pistache::Rest;

LOGINFO("Setting up HomeObject HTTP routes");
struct http_route {
Pistache::Http::Method method;
std::string resource;
Pistache::Rest::Route::Handler handler;
iomgr::url_type type{iomgr::url_type::regular};
};

std::vector< http_route > routes = {
std::vector< iomgr::http_route > routes = {
{Pistache::Http::Method::Get, "/api/v1/getObjLife",
Pistache::Rest::Routes::bind(&HttpManager::get_obj_life, this)},
{Pistache::Http::Method::Get, "/api/v1/mallocStats",
Expand All @@ -46,11 +40,9 @@ HttpManager::HttpManager(HSHomeObject& ho) : ho_(ho) {
};

auto http_server = ioenvironment.get_http_server();
for (auto& route : routes) {
try {
http_server->setup_route(std::move(route.method), route.resource, std::move(route.handler), route.type);
} catch (std::runtime_error const& e) { LOGERROR("setup route {} failed, {}", route.resource, e.what()) }
}
try {
http_server->setup_routes(routes);
} catch (std::runtime_error const& e) { LOGERROR("setup routes failed, {}", e.what()) }
}

void HttpManager::get_obj_life(const Pistache::Rest::Request& request, Pistache::Http::ResponseWriter response) {
Expand Down

0 comments on commit 3ddcb39

Please sign in to comment.