Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

http.createServer should accept suspend function #19

Open
DHosseiny opened this issue Mar 27, 2022 · 1 comment
Open

http.createServer should accept suspend function #19

DHosseiny opened this issue Mar 27, 2022 · 1 comment

Comments

@DHosseiny
Copy link

In http.createServer(RequestListener), RequestListener should be a suspend function. In traditional Js, we can set this function to async and call await inside of it, But without RequestListener being suspend we can not call Promise<T>.await()

@DHosseiny
Copy link
Author

DHosseiny commented Mar 27, 2022

async function myAsync() {
  return 'Hello world'
}

http.createServer(async function (req, res) {
  res.writeHead(200, {'Content-Type': 'text/plain'});
  res.write(await myAsync());
  res.end();
}).listen(3000);

This is working in js.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant