1
0
mirror of https://github.com/mgerb/mywebsite synced 2026-01-10 09:52:51 +00:00
This commit is contained in:
2017-07-25 18:28:20 -05:00
parent 081334ee20
commit c66a8e3def
9 changed files with 106 additions and 62 deletions

View File

@@ -2,22 +2,24 @@ package utils
import (
"encoding/json"
"flag"
"io/ioutil"
"log"
"os"
"../controller/api"
"../db"
"github.com/mgerb/mywebsite/server/controller/api"
"github.com/mgerb/mywebsite/server/db"
)
//structure for application configurations
type Config struct {
Database db.DatabaseInfo `json:"Database"`
Api api.ApiInfo `json:"Api"`
Port int `json:"Port"`
TLSPort int `json:"TLSPort"`
TLSCertFile string `json:"TLSCertFile"`
TLSKeyFile string `json:"TLSKeyFile"`
Database db.DatabaseInfo `json:"Database"`
Api api.ApiInfo `json:"Api"`
Address string `json:"Address"`
}
type Flags struct {
TLS bool
}
//read the config file and return JsonObject struct
@@ -44,3 +46,18 @@ func ReadConfig() Config {
return result
}
func ParseFlags() Flags {
flags := Flags{
TLS: false,
}
tls := flag.Bool("tls", false, "Use TLS")
flag.Parse()
flags.TLS = *tls
return flags
}