lunatic-solutions / lunatic

Lunatic is an Erlang-inspired runtime for WebAssembly
https://lunatic.solutions
Apache License 2.0
4.61k stars 138 forks source link

Http bindings? #84

Open jtenner opened 2 years ago

jtenner commented 2 years ago

A large portion of the AssemblyScript community could really use a way to parse http, and making bindings for something battle tested and safe would be beneficial to help aid in adoption of lunatic by users of AssemblyScript. This might affect other languages like grain which probably don't have http libraries to choose from.

These bindings can also be hidden behind a flag so that binaries remain small for rust developers.

bkolobara commented 2 years ago

I'm generally not against shipping a http server with lunatic. I mean, Go has one in the standard library and they are doing fine :).

If you are interested in taking the time and drafting out a proposal it would be a great starting point. I understand that it's a lot of work, HTTP has a big surface area and is complicated. However, if there is a nice way of modelling it with processes and we can create host functions with good ergonomics, I think it could be a good addition. There are so many things to think about (http1/2/3, tls, websockets, keep-alive, ...) though, it will take us some time until we figure everything out.

Another approach would be to use an existing guest-side web server in lunatic (e.g. https://github.com/bailion/puck) and modify it so that it can spawn processes from AssemblyScript modules. Then you could send all HTTP requests as messages to it and get the responses back as messages. All APIs to make this work already exist in lunatic.