Skip to content

The Go http.Transport interface implemented over the WHATWG Fetch API

Notifications You must be signed in to change notification settings

johanbrandhorst/fetch

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 

Repository files navigation

Fetch

The Go http.Transport interface implemented over the WHATWG Fetch API using the WebAssembly arch target.

Usage

This package requires the Go WASM compilation target to be supported. Short example:

c := http.Client{
    Transport: &fetch.Transport{},
}
resp, err := c.Get("https://api.github.com")
if err != nil {
    fmt.Println(err)
    return
}
defer resp.Body.Close()
b, err := ioutil.ReadAll(resp.Body)
if err != nil {
    fmt.Println(err)
    return
}
fmt.Println(string(b))

See my wasm-experiments repo for the full example of its use.

Attribution

The code is largely based on the Fetch API implementation in GopherJS.

About

The Go http.Transport interface implemented over the WHATWG Fetch API

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages