-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
52 additions
and
6 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 |
---|---|---|
|
@@ -2,4 +2,5 @@ bin | |
config.toml | ||
.db | ||
.modcache | ||
examples/*/*.wasm | ||
examples/*/*.wasm | ||
internal/_testdata/*.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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,7 @@ api: build | |
@./bin/api --seed | ||
|
||
test: | ||
@./internal/_testdata/build.sh | ||
@go test ./internal/* -v | ||
|
||
proto: | ||
|
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 @@ | ||
GOOS=wasip1 GOARCH=wasm go build -o internal/_testdata/helloworld.wasm internal/_testdata/helloworld.go |
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,16 @@ | ||
package main | ||
|
||
import ( | ||
"net/http" | ||
|
||
raptor "github.com/anthdm/raptor/sdk" | ||
) | ||
|
||
func handle(w http.ResponseWriter, r *http.Request) { | ||
w.WriteHeader(http.StatusOK) | ||
w.Write([]byte("Hello world!")) | ||
} | ||
|
||
func main() { | ||
raptor.Handle(http.HandlerFunc(handle)) | ||
} |
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,26 @@ | ||
// This should come from the official SDK. | ||
// But there is no official SDK yet, so we keep it here. | ||
function hexLog(s) { | ||
for (let i = 0; i < s.length; i++) { | ||
putstr(s.charCodeAt(i).toString(16).padStart(2, "0")) | ||
} | ||
putstr("0a") | ||
} | ||
|
||
console.log = hexLog | ||
|
||
function respond(res, status) { | ||
var buffer = new ArrayBuffer(8); | ||
var view = new DataView(buffer); | ||
view.setUint32(0, status, true); | ||
view.setUint32(4, res.length, true); | ||
|
||
for (let i = 0; i < res.length; i++) { | ||
putstr(res.charCodeAt(i).toString(16).padStart(2, "0")) | ||
} | ||
for (let i = 0; i < view.buffer.byteLength; i++) { | ||
putstr(view.getUint8(i).toString(16).padStart(2, "0")); | ||
} | ||
} | ||
|
||
respond("Hello world!", 200) |
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