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){
api->setCalibrationValue(name,value);
}
virtual bool handleWebRequest(const String &url,AsyncWebServerRequest *req){
GWSYNCHRONIZED(&localLock);
auto it=webHandlers.find(url);
if (it == webHandlers.end()){
api->getLogger()->logDebug(GwLog::LOG,"no web handler task=%s url=%s",name.c_str(),url.c_str());
return false;
virtual bool handleWebRequest(const String &url, AsyncWebServerRequest *req)
{
GwApi::HandlerFunction handler;
{
GWSYNCHRONIZED(&localLock);
auto it = webHandlers.find(url);
if (it == webHandlers.end())
{
api->getLogger()->logDebug(GwLog::LOG, "no web handler task=%s url=%s", name.c_str(), url.c_str());
return false;
}
handler = it->second;
}
it->second(req);
if (handler)
handler(req);
return true;
}
};
GwUserCode::GwUserCode(GwApiInternal *api,SemaphoreHandle_t *mainLock){