github.com/Cleverse/go-ethereum@v0.0.0-20220927095127-45113064e7f2/rpc/client_arbitrum.go (about) 1 package rpc 2 3 import ( 4 "context" 5 "fmt" 6 "net/http" 7 "net/url" 8 ) 9 10 func DialTransport(ctx context.Context, rawUrl string, transport *http.Transport) (*Client, error) { 11 u, err := url.Parse(rawUrl) 12 if err != nil { 13 return nil, err 14 } 15 16 var rpcClient *Client 17 switch u.Scheme { 18 case "http", "https": 19 client := &http.Client{ 20 Transport: transport, 21 } 22 rpcClient, err = DialHTTPWithClient(rawUrl, client) 23 case "ws", "wss": 24 rpcClient, err = DialWebsocket(ctx, rawUrl, "") 25 case "stdio": 26 return DialStdIO(ctx) 27 case "": 28 return DialIPC(ctx, rawUrl) 29 default: 30 return nil, fmt.Errorf("no known transport for scheme %q in URL %s", u.Scheme, rawUrl) 31 } 32 if err != nil { 33 return nil, err 34 } 35 return rpcClient, nil 36 }