1
0
mirror of https://github.com/taigrr/wasm-experiments synced 2025-01-18 04:03:21 -08:00
Johan Brandhorst 8e3e7d54de
Couple small changes
Add extra HTTP verbs, Generate verb string representation,
disallow body for GET, HEAD, Use more pointers.
2018-05-12 21:31:00 +01:00

29 lines
482 B
Go

// +build js,wasm
package main
import (
"bytes"
"fmt"
"net/http"
"net/url"
"github.com/johanbrandhorst/wasm-experiments/fetch/fetch"
)
func main() {
headers := http.Header{}
headers.Add("Content-Type", "application/json")
req := &fetch.Request{
URL: &url.URL{
Scheme: "http",
Host: "httpbin.org",
Path: "anything",
},
Method: fetch.POST,
Body: bytes.NewBuffer([]byte(`{"key": "value"}`)),
Headers: headers,
}
fmt.Println(fetch.Fetch(req))
}