Skip to content
Snippets Groups Projects
Commit 07cf1efd authored by Reviath's avatar Reviath
Browse files

Getting web port and base url separately

parent 965ae1c6
No related branches found
No related tags found
No related merge requests found
Pipeline #682 passed
......@@ -8,6 +8,7 @@
"User": "USER",
"Password": "PASSWORD",
"Host": "HOST",
"WebURL": "WEB_URL",
"WebPort": "WEB_PORT",
"BaseURL": "BASE_URL",
"ClientSecret": "CLIENT_SECRET"
}
\ No newline at end of file
......@@ -17,7 +17,8 @@ var (
config *configStruct // config structure
Password string // Password to connect MySQL database
Host string // Host to connect MySQL database
WebURL string // WebURL to run website
WebPort string // WebPort to run website at
BaseURL string // BaseURL to run website at
ClientSecret string // ClientSecret for OAuth2
)
......@@ -31,7 +32,8 @@ type configStruct struct {
Host string `json:"Host"` // Host from config file
User string `json:"User"` // User from config file
Password string `json:"Password"` // Password from config file
WebURL string `json:"WebURL"` // WebURL from config file
WebPort string `json:"WebPort"` // WebURL from config file
BaseURL string `json:"BaseURL"` // BaseURL from config file
ClientSecret string `json:"ClientSecret"` // ClientSecret from config file
}
......@@ -60,7 +62,8 @@ func ReadConfig() error {
User = config.User
Password = config.Password
LoadInteractions = config.LoadInteractions
WebURL = config.WebURL
WebPort = config.WebPort
BaseURL = config.BaseURL
ClientSecret = config.ClientSecret
return nil
......
......@@ -15,7 +15,7 @@ import (
func main() {
config.ReadConfig()
if config.Token == "TOKEN" || config.ClientSecret == "CLIENT_SECRET" || config.WebURL == "WEB_URL" {
if config.Token == "TOKEN" || config.ClientSecret == "CLIENT_SECRET" || config.WebPort == "WEB_PORT" || config.BaseURL == "BASE_URL" {
fmt.Println("Edit config file before running.")
os.Exit(1)
}
......
......@@ -29,7 +29,7 @@ func Listen(session *discordgo.Session) {
cli := GetClientUser(session)
conf := &oauth2.Config{
RedirectURL: fmt.Sprintf("%s/callback", config.WebURL),
RedirectURL: fmt.Sprintf("%s:%s/callback", config.BaseURL, config.WebPort),
ClientID: cli.ID,
ClientSecret: config.ClientSecret,
Scopes: []string{discord.ScopeIdentify, discord.ScopeGuilds},
......@@ -206,10 +206,10 @@ func Listen(session *discordgo.Session) {
}
})
fmt.Printf("Attempting to run website at \"%s\" \n", config.WebURL)
fmt.Printf("Attempting to run website at \"%s:%s\" \n", config.BaseURL, config.WebPort)
time.Sleep(1 * time.Second)
if err := server.Run(config.WebURL[7:]); err != nil {
fmt.Printf("Cannot run website at \"%s\", running on http://localhost:8000.\n", config.WebURL)
if err := server.Run(":" + config.WebPort); err != nil {
fmt.Printf("Cannot run website at \"%s:%s\", running on http://localhost:8000.\n", config.BaseURL, config.WebPort)
server.Run(":8000")
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment