From 040fc4548f235d1ea88c6280dfa275c93292b456 Mon Sep 17 00:00:00 2001 From: Vasiliy Tolstov Date: Fri, 26 Mar 2021 15:44:34 +0300 Subject: [PATCH] client: add TLSConfig option Signed-off-by: Vasiliy Tolstov --- client/options.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/client/options.go b/client/options.go index ac75a971..3fa1ffe8 100644 --- a/client/options.go +++ b/client/options.go @@ -2,6 +2,7 @@ package client import ( "context" + "crypto/tls" "time" "github.com/unistack-org/micro/v3/broker" @@ -52,6 +53,8 @@ type Options struct { PoolSize int // PoolTTL connection pool ttl PoolTTL time.Duration + // TLSConfig specifies tls.Config for secure connection + TLSConfig *tls.Config } // NewCallOptions creates new call options struct @@ -312,6 +315,22 @@ func Lookup(l LookupFunc) Option { } } +// TLSConfig specifies a *tls.Config +func TLSConfig(t *tls.Config) Option { + return func(o *Options) { + // set the internal tls + o.TLSConfig = t + + // set the default transport if one is not + // already set. Required for Init call below. + + // set the transport tls + o.Transport.Init( + transport.TLSConfig(t), + ) + } +} + // Retries sets the retry count when making the request. func Retries(i int) Option { return func(o *Options) {