From b6e4d258f891003c46fb35ece95bbd2dee5a0c76 Mon Sep 17 00:00:00 2001 From: "Hagelstein, Kai" Date: Sun, 15 Oct 2017 10:51:00 +0200 Subject: [PATCH] Moved Let's Encrypt Option from flag to config.json --- config.json | 3 ++- configuration/configuration.go | 4 +++- flags/flags.go | 13 +++++-------- https/https.go | 4 ++-- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/config.json b/config.json index 414a2617..a605b1b6 100644 --- a/config.json +++ b/config.json @@ -3,5 +3,6 @@ "HttpsHostAndPort":":8085", "HttpsUsage":"None", "Url":"http://127.0.0.1:8084", - "HttpsUrl":"https://127.0.0.1:8085" + "HttpsUrl":"https://127.0.0.1:8085", + "UseLetsEncrypt":false } \ No newline at end of file diff --git a/configuration/configuration.go b/configuration/configuration.go index 4662ea92..4e1d0fd2 100644 --- a/configuration/configuration.go +++ b/configuration/configuration.go @@ -3,11 +3,12 @@ package configuration import ( "encoding/json" "errors" - "github.com/kabukky/journey/filenames" "io/ioutil" "log" "reflect" "strings" + + "github.com/kabukky/journey/filenames" ) // Configuration: settings that are neccesary for server configuration @@ -17,6 +18,7 @@ type Configuration struct { HttpsUsage string Url string HttpsUrl string + UseLetsEncrypt bool } func NewConfiguration() *Configuration { diff --git a/flags/flags.go b/flags/flags.go index 604744d5..2badc4e9 100644 --- a/flags/flags.go +++ b/flags/flags.go @@ -6,12 +6,11 @@ import ( ) var ( - UseLetsEncrypt = false - Log = "" - CustomPath = "" - IsInDevMode = false - HttpPort = "" - HttpsPort = "" + Log = "" + CustomPath = "" + IsInDevMode = false + HttpPort = "" + HttpsPort = "" ) func init() { @@ -23,8 +22,6 @@ func init() { } func parseFlags() { - // Check if HTTPS certificates should be automatically generated and renewed using Let's Encypt - flag.BoolVar(&UseLetsEncrypt, "letsencrypt", false, "Use this option to automatically generate and renew the HTTPS certificates using Let's Encypt. Example: -letsencrypt") // Check if the log should be output to a file flag.StringVar(&Log, "log", "", "Use this option to save to log output to a file. Note: Journey needs create, read, and write access to that file. Example: -log=path/to/log.txt") // Check if a custom content path has been provided by the user diff --git a/https/https.go b/https/https.go index 448c5e22..7eb1a379 100644 --- a/https/https.go +++ b/https/https.go @@ -3,12 +3,12 @@ package https import ( "net/http" + "github.com/kabukky/journey/configuration" "github.com/kabukky/journey/filenames" - "github.com/kabukky/journey/flags" ) func StartServer(addr string, handler http.Handler) error { - if flags.UseLetsEncrypt { + if configuration.Config.UseLetsEncrypt { server := buildLetsEncryptServer(addr, handler) return server.ListenAndServeTLS("", "") } else {