Skip to content

Commit 793234c

Browse files
committed
docs(wasm-languages): grain updates
Signed-off-by: Vaughn Dice <[email protected]>
1 parent 1ce2fcc commit 793234c

File tree

1 file changed

+19
-13
lines changed

1 file changed

+19
-13
lines changed

content/wasm-languages/grain.md

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -46,36 +46,42 @@ To use Grain, you will need to [install the Grain toolkit](https://grain-lang.or
4646
Start with a `hello.gr` file:
4747

4848
```
49-
print("content-type: text/plain\n")
50-
print("\n)
51-
print("Hello, World!")
49+
module Main
50+
51+
provide let _start = () => {
52+
print("content-type: text/plain\n")
53+
print("\n)
54+
print("Hello, World!")
55+
}
5256
```
5357

5458
Compile the program with the `grain` compiler:
5559

5660
```console
57-
$ grain hello.gr
61+
$ grain compile --release --use-start-section hello.gr
5862
```
5963

6064
The above will produce a `hello.gr.wasm` file. As usual, you can run `wasmtime hello.gr.wasm` to see the output. The first time you compile a grain application, it will take a long time. After that, compiling is much faster.
6165

6266
To run the WebAssembly app with Spin, create a `spin.toml` file:
6367

6468
```
65-
spin_version = "1"
66-
authors = ["Fermyon Engineering <[email protected]>"]
67-
description = "Grain example."
69+
spin_manifest_version = 2
70+
71+
[application]
6872
name = "spin-grain"
69-
trigger = { type = "http", base = "/" }
7073
version = "1.0.0"
74+
description = "Grain example."
75+
authors = ["Fermyon Engineering <[email protected]>"]
7176
72-
[[component]]
73-
id = "grain-hello"
74-
source = "hello.gr.wasm"
75-
[component.trigger]
77+
[[trigger.http]]
78+
id = "trigger-grain-hello"
79+
component = "grain-hello"
7680
route = "/"
77-
# Spin components written in Grain use the Wagi HTTP executor
7881
executor = { type = "wagi" }
82+
83+
[component.grain-hello]
84+
source = "hello.gr.wasm"
7985
```
8086

8187
From there, you can use `spin up` to start a server, and see the results on `http://localhost:3000`.

0 commit comments

Comments
 (0)