...
1
2
3
4
5 package transport
6
7 import (
8 "context"
9 "net/http"
10
11 "golang.org/x/oauth2/google"
12 "google.golang.org/grpc"
13
14 "google.golang.org/api/internal"
15 "google.golang.org/api/option"
16 gtransport "google.golang.org/api/transport/grpc"
17 htransport "google.golang.org/api/transport/http"
18 )
19
20
21
22
23 func NewHTTPClient(ctx context.Context, opts ...option.ClientOption) (*http.Client, string, error) {
24 return htransport.NewClient(ctx, opts...)
25 }
26
27
28
29 func DialGRPC(ctx context.Context, opts ...option.ClientOption) (*grpc.ClientConn, error) {
30 return gtransport.Dial(ctx, opts...)
31 }
32
33
34
35
36 func DialGRPCInsecure(ctx context.Context, opts ...option.ClientOption) (*grpc.ClientConn, error) {
37 return gtransport.DialInsecure(ctx, opts...)
38 }
39
40
41
42 func Creds(ctx context.Context, opts ...option.ClientOption) (*google.Credentials, error) {
43 var ds internal.DialSettings
44 for _, opt := range opts {
45 opt.Apply(&ds)
46 }
47 return internal.Creds(ctx, &ds)
48 }
49
View as plain text