-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #58 from fermyon/fix-examples
Fix examples
- Loading branch information
Showing
63 changed files
with
2,305 additions
and
1,566 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,10 +7,6 @@ authors = ["Fermyon Engineering <[email protected]>"] | |
[lib] | ||
crate-type = ["cdylib"] | ||
|
||
[package.metadata.component] | ||
package = "component:spin-fileserver-example" | ||
adapter = "adapters/fd1e948d/wasi_snapshot_preview1.reactor.wasm" | ||
|
||
[dependencies] | ||
cargo-component-bindings = "0.4.0" | ||
# Helpful crate to manage errors. | ||
|
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
node_modules/ | ||
http.wasm | ||
composed.wasm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import { handle as spinFileserverHandle } from "wasi:http/[email protected]-rc-2023-10-18" | ||
import { OutgoingResponse, ResponseOutparam, OutgoingBody, Fields } from "wasi:http/[email protected]-rc-2023-10-18" | ||
import { handle as spinFileserverHandle } from "wasi:http/[email protected]" | ||
import { OutgoingResponse, ResponseOutparam, OutgoingBody, Fields } from "wasi:http/[email protected]" | ||
|
||
const encoder = new TextEncoder() | ||
const disposeSymbol = Symbol.dispose || Symbol.for('dispose') | ||
|
@@ -10,14 +10,13 @@ function handle(request, responseOut) { | |
|
||
if (method.tag === "get") { | ||
if (path === "/hello") { | ||
const response = new OutgoingResponse( | ||
200, | ||
new Fields([["content-type", encoder.encode("text/plain")]]) | ||
) | ||
|
||
const fields = new Fields() | ||
fields.append("content-type", encoder.encode("text/plain")) | ||
const response = new OutgoingResponse(fields) | ||
|
||
const responseBody = response.write() | ||
ResponseOutparam.set(responseOut, { tag: "ok", val: response }) | ||
|
||
const responseStream = responseBody.write() | ||
responseStream.blockingWriteAndFlush(encoder.encode("Hello, world!")) | ||
responseStream[disposeSymbol]() | ||
|
@@ -26,7 +25,8 @@ function handle(request, responseOut) { | |
spinFileserverHandle(request, responseOut) | ||
} | ||
} else { | ||
const response = new OutgoingResponse(400, new Fields([])) | ||
const response = new OutgoingResponse(new Fields([])) | ||
response.setSatusCode(400) | ||
ResponseOutparam.set(responseOut, { tag: "ok", val: response }) | ||
OutgoingBody.finish(response.write()) | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.