httpswift / swifter

Tiny http server engine written in Swift programming language.
BSD 3-Clause "New" or "Revised" License
3.87k stars 538 forks source link

How can I call an async function with callback from within the route callback and still be able to return a HttpResponse #517

Closed DubonYaar closed 2 years ago

DubonYaar commented 2 years ago

How can I call an async function with callback from within the route callback and still be able to return a HttpResponse

like so:

let server = HttpServer()
server["/redirect"] = { request in
    callFunctionWithCallback { _ in 
          //How do I return the HttpResponse from within the callback?
    }
}