added check at startup for proxy_url

This commit is contained in:
BroodjeAap 2022-12-30 16:03:58 +00:00
parent a4cebb28b0
commit b954091a8f

13
main.go
View file

@ -10,6 +10,7 @@ import (
"io/ioutil"
"log"
"net/http"
"net/url"
"os"
"strconv"
"strings"
@ -52,13 +53,23 @@ func newWeb() *Web {
func (web *Web) init() {
web.urlCache = make(map[string]string, 5)
web.validateProxyURL()
web.initDB()
web.initRouter()
web.initCronJobs()
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() {
dsn := "./watch.db"
if viper.IsSet("database.dsn") {