Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@ jobs:
go-version: 'stable'
- uses: bytecodealliance/actions/wasmtime/setup@v1
with:
version: "40.0.2"
version: "43.0.0"
- run: rustup update stable --no-self-update && rustup default stable
- run: cargo test --workspace
145 changes: 112 additions & 33 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 15 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ members = ["./tests"]

[workspace.dependencies]
anyhow = "1.0.102"
bzip2 = "0.6.1"
once_cell = "1.21.3"
reqwest = { version = "0.13.1", features = ["blocking"] }
tar = "0.4"

[workspace.package]
version = "0.2.0"
Expand All @@ -34,10 +38,18 @@ unnecessary_cast = 'warn'
allow_attributes_without_reason = 'warn'

[dependencies]
anyhow = { workspace = true}
anyhow = { workspace = true }
bzip2 = { workspace = true }
reqwest = { workspace = true }
tar = { workspace = true }
clap = { version = "4.5.60", features = ["derive"] }
regex = "1.12.3"
wat = { version = "1.245.1"}
wit-bindgen-go = { git = "https://github.com/bytecodealliance/wit-bindgen", rev = "3ee9fe20a5bce398360d5d291e81a4224a6d7c76" }
serde = { version = "1.0.228", features = ["derive"] }
toml = "1.1.0"
# TODO: Switch back to upstream once
# https://github.com/bytecodealliance/wit-bindgen/pull/1572 is merged:
wit-bindgen-go = { git = "https://github.com/dicej/wit-bindgen", rev = "661ade1e" }
wit-component = "0.245.1"
wit-parser = "0.245.1"
which = "8.0.2"
dirs = "6.0.0"
61 changes: 61 additions & 0 deletions examples/multiple-worlds/export_wasi_http_handler/handler.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package export_wasi_http_handler

import (
. "wit_component/wasi_http_types"

. "go.bytecodealliance.org/pkg/wit/types"
)

// Handle the specified `Request`, returning a `Response`
func Handle(request *Request) Result[*Response, ErrorCode] {
method := request.GetMethod().Tag()
path := request.GetPathWithQuery().SomeOr("/")

if method == MethodGet && path == "/hello" {
// Say hello!

tx, rx := MakeStreamU8()

go func() {
defer tx.Drop()
tx.WriteAll([]uint8("Hello, world!"))
}()

response, send := ResponseNew(
FieldsFromList([]Tuple2[string, []byte]{
{F0: "content-type", F1: []byte("text/plain")},
}).Ok(),
Some(rx),
trailersFuture(),
)
send.Drop()

return Ok[*Response, ErrorCode](response)

} else {
// Bad request

response, send := ResponseNew(
MakeFields(),
None[*StreamReader[uint8]](),
trailersFuture(),
)
send.Drop()
response.SetStatusCode(400).Ok()

return Ok[*Response, ErrorCode](response)

}
}

func trailersFuture() *FutureReader[Result[Option[*Fields], ErrorCode]] {
tx, rx := MakeFutureResultOptionFieldsErrorCode()
go tx.Write(Ok[Option[*Fields], ErrorCode](None[*Fields]()))
return rx
}

func unitFuture() *FutureReader[Result[Unit, ErrorCode]] {
tx, rx := MakeFutureResultUnitErrorCode()
go tx.Write(Ok[Unit, ErrorCode](Unit{}))
return rx
}
3 changes: 3 additions & 0 deletions examples/multiple-worlds/export_wit_world/foo.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package export_wit_world

func Foo() {}
Loading
Loading