From 1f082bc731bb82bdfec6b87d7fad4377a4e66c65 Mon Sep 17 00:00:00 2001 From: Kelvin Mwinuka Date: Sat, 7 Sep 2024 00:12:40 +0800 Subject: [PATCH] Added CertKeyPair struct to be passed into WithCertKeyPair. This adds more clarity about what's expected from the user. (#102) --- echovault/config.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/echovault/config.go b/echovault/config.go index 485c371..49d2fdb 100644 --- a/echovault/config.go +++ b/echovault/config.go @@ -77,12 +77,20 @@ func WithMTLS(b ...bool) func(echovault *EchoVault) { } } +// CertKeyPair defines the paths to the cert and key pair files respectively. +type CertKeyPair struct { + Cert string + Key string +} + // WithCertKeyPairs is an option to the NewEchoVault function that allows you to pass a // custom CertKeyPairs to EchoVault. // If not specified, EchoVault will use the default configuration from config.DefaultConfig(). -func WithCertKeyPairs(certKeyPairs [][]string) func(echovault *EchoVault) { +func WithCertKeyPairs(certKeyPairs []CertKeyPair) func(echovault *EchoVault) { return func(echovault *EchoVault) { - echovault.config.CertKeyPairs = certKeyPairs + for _, pair := range certKeyPairs { + echovault.config.CertKeyPairs = append(echovault.config.CertKeyPairs, []string{pair.Cert, pair.Key}) + } } }