diff --git a/ipe/auth.go b/ipe/auth.go index ed7b79f..66094e3 100644 --- a/ipe/auth.go +++ b/ipe/auth.go @@ -50,7 +50,7 @@ func restAuthenticationHandler(h http.Handler) http.Handler { vars := mux.Vars(r) appID := vars["app_id"] - app, err := Conf.GetAppByAppID(appID) + app, err := conf.GetAppByAppID(appID) if err != nil { log.Error(err) diff --git a/ipe/config.go b/ipe/config.go index df16c6c..c76c1e2 100644 --- a/ipe/config.go +++ b/ipe/config.go @@ -18,9 +18,6 @@ type configFile struct { Apps []*app } -// Error for App not found -var AppNotFoundError = errors.New("App not found") - // Initialize Apps func (c *configFile) Init() { for _, app := range c.Apps { @@ -39,7 +36,7 @@ func (c *configFile) GetAppByAppID(appID string) (*app, error) { return a, nil } } - return &app{}, AppNotFoundError + return &app{}, errors.New("App not found") } // Returns an App with by key @@ -49,5 +46,5 @@ func (c *configFile) GetAppByKey(key string) (*app, error) { return a, nil } } - return &app{}, AppNotFoundError + return &app{}, errors.New("App not found") } diff --git a/ipe/extra_handlers.go b/ipe/extra_handlers.go index a17236d..4bf1b5c 100644 --- a/ipe/extra_handlers.go +++ b/ipe/extra_handlers.go @@ -17,7 +17,7 @@ func restCheckAppDisabledHandler(h http.Handler) http.Handler { vars := mux.Vars(r) appID := vars["app_id"] - currentApp, err := Conf.GetAppByAppID(appID) + currentApp, err := conf.GetAppByAppID(appID) if err != nil { http.Error(w, fmt.Sprintf("Could not found an app with app_id: %s", appID), http.StatusForbidden) diff --git a/ipe/ipe.go b/ipe/ipe.go index 1382944..a89194e 100644 --- a/ipe/ipe.go +++ b/ipe/ipe.go @@ -11,7 +11,7 @@ import ( ) // Conf holds the global configuration state -var Conf configFile +var conf configFile // Start Parse the configuration file and starts the ipe server func Start(configfile string) error { @@ -21,14 +21,14 @@ func Start(configfile string) error { return err } - if err := json.Unmarshal(file, &Conf); err != nil { + if err := json.Unmarshal(file, &conf); err != nil { return err } - Conf.Init() + conf.Init() router := newRouter() - if err := http.ListenAndServe(Conf.Host, router); err != nil { + if err := http.ListenAndServe(conf.Host, router); err != nil { return err } diff --git a/ipe/rest.go b/ipe/rest.go index 37a1054..80f59e3 100644 --- a/ipe/rest.go +++ b/ipe/rest.go @@ -33,7 +33,7 @@ func postEvents(w http.ResponseWriter, r *http.Request) { vars := mux.Vars(r) appID := vars["app_id"] - app, err := Conf.GetAppByAppID(appID) + app, err := conf.GetAppByAppID(appID) if err != nil { http.Error(w, fmt.Sprintf("Could not found an app with app_id: %s", appID), http.StatusBadRequest) @@ -120,7 +120,7 @@ func getChannels(w http.ResponseWriter, r *http.Request) { return } - app, err := Conf.GetAppByAppID(appID) + app, err := conf.GetAppByAppID(appID) if err != nil { http.Error(w, fmt.Sprintf("Could not found an app with app_id: %s", appID), http.StatusBadRequest) @@ -183,7 +183,7 @@ func getChannel(w http.ResponseWriter, r *http.Request) { vars := mux.Vars(r) appID := vars["app_id"] - app, err := Conf.GetAppByAppID(appID) + app, err := conf.GetAppByAppID(appID) if err != nil { http.Error(w, fmt.Sprintf("Could not found an app with app_id: %s", appID), http.StatusBadRequest) @@ -279,7 +279,7 @@ func getChannelUsers(w http.ResponseWriter, r *http.Request) { return } - app, err := Conf.GetAppByAppID(appID) + app, err := conf.GetAppByAppID(appID) if err != nil { http.Error(w, fmt.Sprintf("Could not found an app with app_id: %s", appID), http.StatusBadRequest) diff --git a/ipe/router.go b/ipe/router.go index 61b32de..71d41b3 100644 --- a/ipe/router.go +++ b/ipe/router.go @@ -17,12 +17,12 @@ import ( func newRouter() *mux.Router { router := mux.NewRouter().StrictSlash(true) - if Conf.Expvar { - if !Conf.WasProvidedUserAndPassword() { + if conf.Expvar { + 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)) + router.Handle("/debug/vars", httpauth.SimpleBasicAuth(conf.User, conf.Password)(http.DefaultServeMux)) } for _, route := range routes { diff --git a/ipe/websockets.go b/ipe/websockets.go index 1b49dbd..71f906e 100644 --- a/ipe/websockets.go +++ b/ipe/websockets.go @@ -218,7 +218,7 @@ func wsHandler(w http.ResponseWriter, r *http.Request) { vars := mux.Vars(r) appKey := vars["key"] - app, err := Conf.GetAppByKey(appKey) + app, err := conf.GetAppByKey(appKey) if err != nil { log.Error(err)