Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Moved Let's Encrypt Option from flag to config.json #103

Merged
merged 1 commit into from
Oct 15, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion config.json
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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