DialHTTPWithClient creates a new RPC client that connects to an RPC server over HTTP using the provided HTTP Client.
(endpoint string, client *http.Client)
| 69 | // DialHTTPWithClient creates a new RPC client that connects to an RPC server over HTTP |
| 70 | // using the provided HTTP Client. |
| 71 | func DialHTTPWithClient(endpoint string, client *http.Client) (*Client, error) { |
| 72 | req, err := http.NewRequest(http.MethodPost, endpoint, nil) |
| 73 | if err != nil { |
| 74 | return nil, err |
| 75 | } |
| 76 | req.Header.Set("Content-Type", contentType) |
| 77 | req.Header.Set("Accept", contentType) |
| 78 | |
| 79 | initctx := context.Background() |
| 80 | return newClient(initctx, func(context.Context) (net.Conn, error) { |
| 81 | return &httpConn{client: client, req: req, closed: make(chan struct{})}, nil |
| 82 | }) |
| 83 | } |
| 84 | |
| 85 | // DialHTTP creates a new RPC client that connects to an RPC server over HTTP. |
| 86 | func DialHTTP(endpoint string) (*Client, error) { |