Skip to content

Commit 0a3c7c8

Browse files
authored
improve: support js,wasm (#683)
1 parent 6ea5279 commit 0a3c7c8

File tree

3 files changed

+35
-1
lines changed

3 files changed

+35
-1
lines changed

transport.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ func createTransport(localAddr net.Addr) *http.Transport {
2525
}
2626
return &http.Transport{
2727
Proxy: http.ProxyFromEnvironment,
28-
DialContext: dialer.DialContext,
28+
DialContext: transportDialContext(dialer),
2929
ForceAttemptHTTP2: true,
3030
MaxIdleConns: 100,
3131
IdleConnTimeout: 90 * time.Second,

transport_js.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Copyright 2021 The Go Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style
3+
// license that can be found in the LICENSE file.
4+
5+
//go:build js && wasm
6+
// +build js,wasm
7+
8+
package resty
9+
10+
import (
11+
"context"
12+
"net"
13+
)
14+
15+
func transportDialContext(dialer *net.Dialer) func(context.Context, string, string) (net.Conn, error) {
16+
return nil
17+
}

transport_other.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Copyright 2021 The Go Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style
3+
// license that can be found in the LICENSE file.
4+
5+
//go:build !(js && wasm)
6+
// +build !js !wasm
7+
8+
package resty
9+
10+
import (
11+
"context"
12+
"net"
13+
)
14+
15+
func transportDialContext(dialer *net.Dialer) func(context.Context, string, string) (net.Conn, error) {
16+
return dialer.DialContext
17+
}

0 commit comments

Comments
 (0)