wa-lang.org/wazero@v1.0.2/internal/gojs/testdata/http/main.go (about) 1 package http 2 3 import ( 4 "fmt" 5 "io" 6 "log" 7 "net/http" 8 "os" 9 "strings" 10 ) 11 12 func Main() { 13 url := os.Getenv("BASE_URL") 14 res, err := http.Get(url + "/error") 15 if err == nil { 16 log.Panicln(err) 17 } 18 fmt.Println(err) 19 20 res, err = http.Post(url, "text/plain", io.NopCloser(strings.NewReader("ice cream"))) 21 if err != nil { 22 log.Panicln(err) 23 } 24 body, err := io.ReadAll(res.Body) 25 if err != nil { 26 log.Panicln(err) 27 } 28 res.Body.Close() 29 30 fmt.Println(res.Header.Get("Custom")) 31 fmt.Println(string(body)) 32 }