From d87b96e62ee58f5770760d737105c81f7f18a49c Mon Sep 17 00:00:00 2001 From: Nikita Tokarchuk Date: Sat, 11 Dec 2021 02:39:28 +0100 Subject: [PATCH] Add backend is-secure configuration --- frontend/config/config.go | 16 ++++++++++++---- frontend/main.go | 4 ++-- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/frontend/config/config.go b/frontend/config/config.go index 59a9949..87eef5a 100644 --- a/frontend/config/config.go +++ b/frontend/config/config.go @@ -8,12 +8,18 @@ import ( "github.com/spf13/viper" ) +// Backend contains backend connection-specific configuration +type Backend struct { + Addr string `mapstructure:"addr"` + Secured bool `mapstructure:"secured"` +} + // Content contains content-specific configuration type Content struct { - Backend string `mapstructure:"backend"` - Key string `mapstructure:"key"` - Pinned string `mapstructure:"pinned"` - PostsPerPage int `mapstructure:"postsPerPage"` + Backend Backend `mapstructure:"backend"` + Key string `mapstructure:"key"` + Pinned string `mapstructure:"pinned"` + PostsPerPage int `mapstructure:"postsPerPage"` } // Config contains application configuration @@ -36,6 +42,8 @@ func init() { pflag.String("unix", "", "unix socket path to listen") pflag.String("base", "", "http URI prefix") + pflag.String("content.backend.addr", "demo.ghost.io:443", "ghost backend addr") + pflag.Bool("content.backend.secured", true, "is ghost backend secured") pflag.String("content.backend", "demo.ghost.io:443", "ghost backend addr") pflag.String("content.key", "22444f78447824223cefc48062", "ghost content api key") pflag.String("content.pinned", "contact", "pinned page slug") diff --git a/frontend/main.go b/frontend/main.go index a15f26d..89902fd 100644 --- a/frontend/main.go +++ b/frontend/main.go @@ -54,9 +54,9 @@ func main() { } ghostClient := &ghost.HTTPClient{ - Addr: config.Content.Backend, + Addr: config.Content.Backend.Addr, + Secured: config.Content.Backend.Secured, ContentKey: config.Content.Key, - Secured: true, QueryTimeout: time.Second, }