subhub/app/app.go

47 lines
972 B
Go
Raw Normal View History

2019-09-07 14:54:53 +00:00
package app
import (
"database/sql"
"flag"
"log"
"os"
)
const (
serverName = "Sub Hub"
softwareVer = "0.0.1"
configFile = "config.json"
)
type app struct {
db *sql.DB
cfg *config
}
type config struct {
Host string `json:"host"`
Port int `json:"port"`
MySQLConnStr string `json:"mysql_conn_str"`
Name string `json:"instance_name"`
}
func Serve() {
app := &app{
cfg: &config{},
}
var newUser, newPass string
flag.IntVar(&app.cfg.Port, "p", 8090, "Port to start server on")
flag.StringVar(&app.cfg.Host, "h", "", "Serer base URL")
// options for creating a new user
flag.StringVar(&newUser, "user", "", "New user's username. Should be paired with --pass")
flag.StringVar(&newPass, "pass", "", "Password for new user. Should be paired with --user")
flag.Parse()
if app.cfg.Host == "" || os.Getenv("SH_MYSQL_CONNECTION") == "" {
log.Printf("Reding %s", configFile)
//f, err := ioutil.ReadFile(configFile)
}
}