Skip to content
Open
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
28 changes: 19 additions & 9 deletions docs/quickstart/develop-a-webassembly-component.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,10 @@ async fn home(req: Request<Body>) -> Result<Response<Body>, wstd::http::Error> {
}

async fn not_found(_req: Request<Body>) -> Result<Response<Body>, wstd::http::Error> {
Ok(Response::builder()
Response::builder()
.status(StatusCode::NOT_FOUND)
.body("Not found\n".into())
.unwrap())
.map_err(Into::into)
}
```

Expand Down Expand Up @@ -178,11 +178,9 @@ world hello {
import wasi:keyvalue/store@0.2.0-draft;
// [!code ++]
import wasi:keyvalue/atomics@0.2.0-draft;
// [!code ++]

export wasi:http/incoming-handler@0.2.9;
}
```

</TabItem>
<TabItem value="typescript" label="TypeScript">

Expand All @@ -198,7 +196,7 @@ world typescript-http-hello-world-hono {
import wasi:keyvalue/atomics@0.2.0-draft;
// [!code ++]

export wasi:http/incoming-handler@0.2.9;
export wasi:http/incoming-handler@0.2.6;
}
```

Expand Down Expand Up @@ -285,7 +283,7 @@ async fn home(req: Request<Body>) -> Result<Response<Body>, wstd::http::Error> {
let bucket = store::open("") // [!code ++]
.map_err(|e| wstd::http::Error::msg(format!("keyvalue open error: {:?}", e)))?; // [!code ++]

let count = atomics::increment(&bucket, &name, 1) // [!code ++]
let count = atomics::increment(&bucket, name, 1) // [!code ++]
.map_err(|e| wstd::http::Error::msg(format!("keyvalue increment error: {:?}", e)))?; // [!code ++]

// Return greeting with count // [!code ++]
Expand All @@ -295,15 +293,21 @@ async fn home(req: Request<Body>) -> Result<Response<Body>, wstd::http::Error> {
}

async fn not_found(_req: Request<Body>) -> Result<Response<Body>, wstd::http::Error> {
Ok(Response::builder()
Response::builder()
.status(StatusCode::NOT_FOUND)
.body("Not found\n".into())
.unwrap())
.map_err(Into::into)
}
```

We've made changes, so once we save, the toolchain will once again automatically update the running application.

:::tip[See the working version]

You can find the end-state Rust component for this section [in the main wasmCloud repo](https://github.com/wasmCloud/wasmCloud/tree/main/examples/http-hello-world-persistent-storage).

:::

</TabItem>
<TabItem value="typescript" label="TypeScript">

Expand Down Expand Up @@ -341,6 +345,12 @@ export { incomingHandler } from '@bytecodealliance/jco-std/wasi/0.2.x/http/adapt

We've made changes, so once we save, the toolchain will once again automatically update the running application.

:::tip[See the working version]

You can find the end-state TypeScript component for this section [in the `wasmCloud/typescript` repo](https://github.com/wasmCloud/typescript/tree/main/examples/components/http-hello-world-hono-persistent-storage).

:::

</TabItem>
{/*
<TabItem value="tinygo" label="Go">
Expand Down
Loading