call requestHandler in user code outside of the API lock

This commit is contained in:
andreas 2024-11-15 16:52:11 +01:00
parent 5adf483220
commit bf03de68ac
1 changed files with 14 additions and 8 deletions

View File

@ -340,17 +340,23 @@ public:
virtual void setCalibrationValue(const String &name, double value){ virtual void setCalibrationValue(const String &name, double value){
api->setCalibrationValue(name,value); api->setCalibrationValue(name,value);
} }
virtual bool handleWebRequest(const String &url,AsyncWebServerRequest *req){ virtual bool handleWebRequest(const String &url, AsyncWebServerRequest *req)
{
GwApi::HandlerFunction handler;
{
GWSYNCHRONIZED(&localLock); GWSYNCHRONIZED(&localLock);
auto it=webHandlers.find(url); auto it = webHandlers.find(url);
if (it == webHandlers.end()){ if (it == webHandlers.end())
api->getLogger()->logDebug(GwLog::LOG,"no web handler task=%s url=%s",name.c_str(),url.c_str()); {
api->getLogger()->logDebug(GwLog::LOG, "no web handler task=%s url=%s", name.c_str(), url.c_str());
return false; return false;
} }
it->second(req); handler = it->second;
}
if (handler)
handler(req);
return true; return true;
} }
}; };
GwUserCode::GwUserCode(GwApiInternal *api,SemaphoreHandle_t *mainLock){ GwUserCode::GwUserCode(GwApiInternal *api,SemaphoreHandle_t *mainLock){