Skip to content

Commit f06b75e

Browse files
committed
📦 updates HDK for v0.0.4
1 parent 2348991 commit f06b75e

File tree

5 files changed

+72
-3
lines changed

5 files changed

+72
-3
lines changed

Taskfile.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@ tasks:
2222
env:
2323
#TAG: "v0.0.1"
2424
#TAG: "v0.0.2"
25-
TAG: "v0.0.3" # current release
26-
#TAG: "v0.0.4" # it will be the next release
25+
#TAG: "v0.0.3"
26+
TAG: "v0.0.4" # current release
27+
#TAG: "v0.0.5" # it will be the next release
2728
cmds:
2829
- echo "📦 Generating release..."
2930
- git add .

capsule.dk.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,4 +104,3 @@ func CallOnStop(ctx context.Context, runtime wazero.Runtime, wasmFile []byte) {
104104
}
105105
}
106106
}
107-

docs/helpers.md

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# 🧰 Helpers
2+
3+
> 🚧 this is a work in progress
4+
5+
## Call OnStart exported method (from the wasm module)
6+
> introduced in v0.0.4
7+
8+
```golang
9+
// Package main
10+
package main
11+
12+
import (
13+
"strconv"
14+
"github.com/bots-garden/capsule-module-sdk"
15+
)
16+
17+
func main() {
18+
capsule.SetHandleHTTP(func (param capsule.HTTPRequest) (capsule.HTTPResponse, error) {
19+
return capsule.HTTPResponse{
20+
TextBody: "👋 Hey",
21+
Headers: `{"Content-Type": "text/plain; charset=utf-8"}`,
22+
StatusCode: 200,
23+
}, nil
24+
25+
})
26+
}
27+
28+
// OnStart function
29+
//export OnStart
30+
func OnStart() {
31+
capsule.Print("🚗 OnStart")
32+
}
33+
```
34+
> 👋 don't forget to export the `OnStart` function
35+
36+
## Call OnStop exported method (from the wasm module)
37+
> introduced in v0.0.4
38+
39+
```golang
40+
// Package main
41+
package main
42+
43+
import (
44+
"strconv"
45+
"github.com/bots-garden/capsule-module-sdk"
46+
)
47+
48+
func main() {
49+
capsule.SetHandleHTTP(func (param capsule.HTTPRequest) (capsule.HTTPResponse, error) {
50+
return capsule.HTTPResponse{
51+
TextBody: "👋 Hey",
52+
Headers: `{"Content-Type": "text/plain; charset=utf-8"}`,
53+
StatusCode: 200,
54+
}, nil
55+
56+
})
57+
}
58+
59+
60+
// OnStop function
61+
//export OnStop
62+
func OnStop() {
63+
capsule.Print("🚙 OnStop")
64+
}
65+
```
66+
> 👋 don't forget to export the `OnStop` function

docs/index.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Capsule Host SDK
22

33
!!! info "What's new?"
4+
- `v0.0.4`: ✨ Helpers added: `CallOnStart` and `CallOnStop`
5+
- `v0.0.3`: ✨ Wazero update 1.2.0
46
- `v0.0.2`: ✨ Redis support
57
- `v0.0.1`: 🎉 first release
68

mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ nav:
1616
- 📝 Developer guide:
1717
- First Capsule application: first-capsule-app.md
1818
- 🛠️ Host functions: host-functions.md
19+
- 🧰 Helpers: helpers.md
1920

2021
theme:
2122
name: material

0 commit comments

Comments
 (0)