sensors: move callback from lambda to inline functions with bind_front

bind_front + function is more readable than local lambdas.

Tested:
Tested sensor collection, works as expected.

Signed-off-by: Nan Zhou <nanzhoumails@gmail.com>
Change-Id: Ib3bd6d4249df97c4be5afcd1393477ed424f5de8
diff --git a/redfish-core/lib/sensors.hpp b/redfish-core/lib/sensors.hpp
index 25ac5e0..2e314ac 100644
--- a/redfish-core/lib/sensors.hpp
+++ b/redfish-core/lib/sensors.hpp
@@ -2921,6 +2921,39 @@
     getChassisData(resp);
 }
 
+namespace sensors
+{
+inline void getChassisCallback(
+    const std::shared_ptr<SensorsAsyncResp>& asyncResp,
+    const std::shared_ptr<boost::container::flat_set<std::string>>& sensorNames)
+{
+    BMCWEB_LOG_DEBUG << "getChassisCallback enter";
+
+    nlohmann::json& entriesArray =
+        asyncResp->asyncResp->res.jsonValue["Members"];
+    for (auto& sensor : *sensorNames)
+    {
+        BMCWEB_LOG_DEBUG << "Adding sensor: " << sensor;
+
+        sdbusplus::message::object_path path(sensor);
+        std::string sensorName = path.filename();
+        if (sensorName.empty())
+        {
+            BMCWEB_LOG_ERROR << "Invalid sensor path: " << sensor;
+            messages::internalError(asyncResp->asyncResp->res);
+            return;
+        }
+        entriesArray.push_back(
+            {{"@odata.id", "/redfish/v1/Chassis/" + asyncResp->chassisId + "/" +
+                               asyncResp->chassisSubNode + "/" + sensorName}});
+    }
+
+    asyncResp->asyncResp->res.jsonValue["Members@odata.count"] =
+        entriesArray.size();
+    BMCWEB_LOG_DEBUG << "getChassisCallback exit";
+}
+} // namespace sensors
+
 inline void requestRoutesSensorCollection(App& app)
 {
     BMCWEB_ROUTE(app, "/redfish/v1/Chassis/<str>/Sensors/")
@@ -2941,44 +2974,10 @@
                         aResp, chassisId,
                         sensors::dbus::paths.at(sensors::node::sensors),
                         sensors::node::sensors);
-
-                auto getChassisCb =
-                    [asyncResp](const std::shared_ptr<
-                                boost::container::flat_set<std::string>>&
-                                    sensorNames) {
-                        BMCWEB_LOG_DEBUG << "getChassisCb enter";
-
-                        nlohmann::json& entriesArray =
-                            asyncResp->asyncResp->res.jsonValue["Members"];
-                        for (auto& sensor : *sensorNames)
-                        {
-                            BMCWEB_LOG_DEBUG << "Adding sensor: " << sensor;
-
-                            sdbusplus::message::object_path path(sensor);
-                            std::string sensorName = path.filename();
-                            if (sensorName.empty())
-                            {
-                                BMCWEB_LOG_ERROR << "Invalid sensor path: "
-                                                 << sensor;
-                                messages::internalError(
-                                    asyncResp->asyncResp->res);
-                                return;
-                            }
-                            entriesArray.push_back(
-                                {{"@odata.id", "/redfish/v1/Chassis/" +
-                                                   asyncResp->chassisId + "/" +
-                                                   asyncResp->chassisSubNode +
-                                                   "/" + sensorName}});
-                        }
-
-                        asyncResp->asyncResp->res
-                            .jsonValue["Members@odata.count"] =
-                            entriesArray.size();
-                        BMCWEB_LOG_DEBUG << "getChassisCb exit";
-                    };
-
                 // Get set of sensors in chassis
-                getChassis(asyncResp, std::move(getChassisCb));
+                getChassis(
+                    asyncResp,
+                    std::bind_front(sensors::getChassisCallback, asyncResp));
                 BMCWEB_LOG_DEBUG << "SensorCollection doGet exit";
             });
 }