I am trying to implement a web server in ESP8266 that will handle simple HTTP GET requests by initiating an operation (e.g. move a stepper motor to the requested position) and return a response when the operation is finished (i.e. when the motor has reached the target position). This may take a few seconds, but during that time the main loop should run normally so that both the TCP stack can work and the stepper library can actually move the motor (it works in the background). This means I cannot wait for the operation to complete within the handler. I have to start the operation in the handler, return without sending back a response and when the operation is done (i can poll for that in the main loop) then send the response.
I have been looking at https://github.com/me-no-dev/ESPAsyncWebServer but I'm not sure if such a scenario is supported. Has anynone done anything similar? Is it even possible?
One solution I was thinking was to store the request in a global variable (or queue) before exiting the handler and use it when the operation finishes. But will the request survive outside of the handler? And is it even possible to send the response outside the handler?