feat(http-server): Add WASI reactor support to http-server cap #359
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR switches the WASI command model to reactor model for wasi-http. The reason for that is in the command model, each exported HTTP handler function would not be able to initialize properly with the WASI stdout because the host will not invoke
_start
. The reactor solves this issue.Breaking changes
cargo new --lib
to create the rust program, instead of--bin
. This will create a rust library. In Cargo.toml, the following attribute is needed:slight_http_server_macro::on_server_init
macro on top of the router and server setup function.A rust slight program that uses http-server capability would end up looking like
A Note to Reviewers
I've tested that the http handler would work with keyvalue capability correctly. I still need to add more docs to this newly added macro and changes to the slight runtime library, but other than that, this PR is ready to review.