The handler func is called when the client calls this endpoint, *by definition* of what a handler function is.
Depending on how your application is designed, you can either do work in the handler func, or you can make a note that some work needs to be done (for example, by putting a message in a buffered channel). If the latter, then a separate part of your application will pick up the task to be done. If you do it that way, it will be too late to return a success or fail result to the client.
Beware that multiple clients can call your handler func concurrently, in separate but overlapping HTTP requests. Therefore your code needs to be concurrency-safe.