mirror of
https://github.com/syumai/workers.git
synced 2025-03-10 17:29:11 +00:00
R: fix service-bindings example
This commit is contained in:
parent
6420c959e8
commit
3f7d0e77f2
@ -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:
|
||||
|
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user