mirror of
https://github.com/lukaszraczylo/go-simple-graphql.git
synced 2026-10-17 01:17:43 +00:00
Use dialer to automagically pick between https and http endpoints.
This commit is contained in:
@@ -15,9 +15,11 @@ package gql
|
||||
import (
|
||||
"crypto/tls"
|
||||
"fmt"
|
||||
"net"
|
||||
"net/http"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
bigcache "github.com/allegro/bigcache/v3"
|
||||
@@ -85,6 +87,12 @@ func NewConnection() *GraphQL {
|
||||
Endpoint: pickGraphqlEndpoint(),
|
||||
HttpClient: &http.Client{
|
||||
Transport: &http2.Transport{
|
||||
DialTLS: func(network, addr string, cfg *tls.Config) (net.Conn, error) {
|
||||
if strings.HasPrefix(network, "http") {
|
||||
return net.Dial(network, addr)
|
||||
}
|
||||
return tls.Dial(network, addr, cfg)
|
||||
},
|
||||
ReadIdleTimeout: 30 * time.Second,
|
||||
DisableCompression: false,
|
||||
AllowHTTP: true,
|
||||
|
||||
Reference in New Issue
Block a user