Skip to content

Commit

Permalink
improve: support js,wasm (#683)
Browse files Browse the repository at this point in the history
  • Loading branch information
shynome committed Sep 17, 2023
1 parent 6ea5279 commit 0a3c7c8
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 1 deletion.
2 changes: 1 addition & 1 deletion transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func createTransport(localAddr net.Addr) *http.Transport {
}
return &http.Transport{
Proxy: http.ProxyFromEnvironment,
DialContext: dialer.DialContext,
DialContext: transportDialContext(dialer),
ForceAttemptHTTP2: true,
MaxIdleConns: 100,
IdleConnTimeout: 90 * time.Second,
Expand Down
17 changes: 17 additions & 0 deletions transport_js.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Copyright 2021 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

//go:build js && wasm
// +build js,wasm

package resty

import (
"context"
"net"
)

func transportDialContext(dialer *net.Dialer) func(context.Context, string, string) (net.Conn, error) {
return nil
}
17 changes: 17 additions & 0 deletions transport_other.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Copyright 2021 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

//go:build !(js && wasm)
// +build !js !wasm

package resty

import (
"context"
"net"
)

func transportDialContext(dialer *net.Dialer) func(context.Context, string, string) (net.Conn, error) {
return dialer.DialContext
}

0 comments on commit 0a3c7c8

Please sign in to comment.