Skip to content

Commit

Permalink
Merge pull request #103 from kabukky/development
Browse files Browse the repository at this point in the history
Moved Let's Encrypt Option from flag to config.json
  • Loading branch information
kabukky committed Oct 15, 2017
2 parents 9a138d2 + b6e4d25 commit 58d81ca
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
3 changes: 2 additions & 1 deletion config.json
Expand Up @@ -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
}
4 changes: 3 additions & 1 deletion configuration/configuration.go
Expand Up @@ -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
Expand All @@ -17,6 +18,7 @@ type Configuration struct {
HttpsUsage string
Url string
HttpsUrl string
UseLetsEncrypt bool
}

func NewConfiguration() *Configuration {
Expand Down
13 changes: 5 additions & 8 deletions flags/flags.go
Expand Up @@ -6,12 +6,11 @@ import (
)

var (
UseLetsEncrypt = false
Log = ""
CustomPath = ""
IsInDevMode = false
HttpPort = ""
HttpsPort = ""
Log = ""
CustomPath = ""
IsInDevMode = false
HttpPort = ""
HttpsPort = ""
)

func init() {
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions https/https.go
Expand Up @@ -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 {
Expand Down

0 comments on commit 58d81ca

Please sign in to comment.