added check at startup for proxy_url
This commit is contained in:
parent
a4cebb28b0
commit
b954091a8f
1 changed files with 12 additions and 1 deletions
13
main.go
13
main.go
|
@ -10,6 +10,7 @@ import (
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -52,13 +53,23 @@ func newWeb() *Web {
|
||||||
|
|
||||||
func (web *Web) init() {
|
func (web *Web) init() {
|
||||||
web.urlCache = make(map[string]string, 5)
|
web.urlCache = make(map[string]string, 5)
|
||||||
|
web.validateProxyURL()
|
||||||
web.initDB()
|
web.initDB()
|
||||||
|
|
||||||
web.initRouter()
|
web.initRouter()
|
||||||
web.initCronJobs()
|
web.initCronJobs()
|
||||||
web.initNotifiers()
|
web.initNotifiers()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (web *Web) validateProxyURL() {
|
||||||
|
if viper.IsSet("proxy.proxy_url") {
|
||||||
|
_, err := url.Parse(viper.GetString("proxy.proxy_url"))
|
||||||
|
if err != nil {
|
||||||
|
log.Println("Could not parse proxy url, check config")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (web *Web) initDB() {
|
func (web *Web) initDB() {
|
||||||
dsn := "./watch.db"
|
dsn := "./watch.db"
|
||||||
if viper.IsSet("database.dsn") {
|
if viper.IsSet("database.dsn") {
|
||||||
|
|
Loading…
Add table
Reference in a new issue