I'm getting into ESP as WebServer as began using the ESPAsyncWebServer Library. One method I don't quite understand is the server.on()
server.on("/", HTTP_GET, [](AsyncWebServerRequest *request){
request->send_P(200, "text/html", index_html, processor);
});
How are you able to pass a full function as a parameter? All I know is to create a function separately and then call it later on or pass it as a reference into a method or another function.
For now I've been using it as the examples showed to me but I have no idea how it works. I thought it would be interesting to be able to use in my own codes.
I looked into the library to try and figure out how to use it and create it myself and quickly got confused with all the source files. I never saw an example like this before and can not find it explained on the forum anywhere
Mostly im interested in how they pass the function with brackets and everything. Ive seen something similar in js but didn't understand it either
If anyone can help me understand this, that would be sweet!
Thank you.