ESP8266WebServer invalid use of void expression

I was reading the class reference but im not sure what THandlerFunction fn/ufn mean. Im trying to call a function that takes args but it give me error invalid use of a void expression. This is what they have documented about on();

void    on (const char *uri, THandlerFunction handler)

void    on (const char *uri, HTTPMethod method, THandlerFunction fn)

void    on (const char *uri, HTTPMethod method, THandlerFunction fn, THandlerFunction ufn)

currently i call a function that calls a function like this,

server.on("/stoptm1t3", handleStoptm1t3);

void handleStoptm1t3() {
  sendMessage("T3STOPPOTS3T", _EEPROM.TM1_IP, ServerPort);
}

but i dont want to call so many functions. how can/ can i call it like this with server.on() ?

i tried this but it gives me compiler error about invalid use of expression,

server.on("/stoptm1t3",  sendMessage("T3STOPPOTS3T", _EEPROM.TM1_IP, ServerPort));

but i dont want to call so many functions

How many functions ? You know you will still need to make a reference to the callback function anyway. If you want to pass an argument, you should do so as part of the URL and extract them within the callback function.

Use a lambda function:

server.on("/stoptm1t3",  []{ sendMessage("T3STOPPOTS3T", _EEPROM.TM1_IP, ServerPort); });

Pieter

PieterP: Use a lambda function:

server.on("/stoptm1t3",  []{ sendMessage("T3STOPPOTS3T", _EEPROM.TM1_IP, ServerPort); });

Pieter

lambda function, interesting. thankyou this is exactly what was looking for