R: fix service-bindings example

This commit is contained in:
aki-0421 2023-04-11 21:35:09 +09:00
parent 6420c959e8
commit 3f7d0e77f2
No known key found for this signature in database
GPG Key ID: 64A8CF6D437D166A
2 changed files with 6 additions and 11 deletions

View File

@ -5,7 +5,8 @@ dev:
.PHONY: build
build:
mkdir -p dist
tinygo build -o ./dist/app.wasm -target wasm ./...
#tinygo build -o ./dist/app.wasm -target wasm ./...
tinygo build -o ./dist/app.wasm -target wasm -no-debug ./...
.PHONY: publish
publish:

View File

@ -13,17 +13,11 @@ import (
func main() {
handler := http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
ctx := req.Context()
bind := cloudflare.GetBinding(ctx, "hello")
fc := fetch.NewClient(fetch.WithBinding(bind))
obj := cloudflare.GetBinding(ctx, "hello")
cli := fetch.NewClient(fetch.WithBinding(obj))
r, err := fetch.NewRequest(ctx, http.MethodGet, req.URL.String(), nil)
if err != nil {
fmt.Println(err)
w.WriteHeader(http.StatusInternalServerError)
return
}
res, err := cli.Do(r)
hc := fc.HTTPClient()
res, err := hc.Do(req)
if err != nil {
fmt.Println(err)
w.WriteHeader(http.StatusInternalServerError)