github.com/0chain/gosdk@v1.17.11/core/resty/client_wasm.go (about) 1 //go:build js && wasm 2 // +build js,wasm 3 4 package resty 5 6 import ( 7 "net/http" 8 "time" 9 ) 10 11 // CreateClient a function that create a client instance 12 var CreateClient = func(t *http.Transport, timeout time.Duration) Client { 13 c := &WasmClient{ 14 Client: &http.Client{ 15 Transport: t, 16 }, 17 } 18 19 if timeout > 0 { 20 c.Client.Timeout = timeout 21 } 22 23 return c 24 } 25 26 type WasmClient struct { 27 *http.Client 28 } 29 30 func (c *WasmClient) Do(req *http.Request) (*http.Response, error) { 31 req.Header.Set("js.fetch:mode", "cors") 32 33 return c.Client.Do(req) 34 }