CLeanup the User and Password checking

Added a Method in ConfigFile
This commit is contained in:
claudemiro
2015-01-13 08:10:47 -03:00
parent 0aec168ab3
commit 2cb8b13dc6
2 changed files with 10 additions and 4 deletions
+2 -3
View File
@@ -8,7 +8,6 @@ import (
_ "expvar"
"net/http"
"os"
"strings"
"github.com/goji/httpauth"
"github.com/gorilla/handlers"
@@ -21,8 +20,8 @@ func NewRouter() *mux.Router {
router := mux.NewRouter().StrictSlash(true)
if Conf.Expvar {
if len(strings.TrimSpace(Conf.User)) == 0 || len(strings.TrimSpace(Conf.Password)) == 0 {
panic("Your are exporting debug variables and you are not defining an User and a Password")
if !Conf.WasProvidedUserAndPassword() {
panic("Your are exporting debug variables and looks like you forget to define an User and a Password")
}
router.Handle("/debug/vars", httpauth.SimpleBasicAuth(Conf.User, Conf.Password)(http.DefaultServeMux))