Not necessary export conf.

This commit is contained in:
claudemiro
2015-01-31 15:18:38 -03:00
parent 201cba86a9
commit 846231f5f3
7 changed files with 16 additions and 19 deletions
+1 -1
View File
@@ -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)
+2 -5
View File
@@ -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")
}
+1 -1
View File
@@ -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)
+4 -4
View File
@@ -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
}
+4 -4
View File
@@ -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)
+3 -3
View File
@@ -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 {
+1 -1
View File
@@ -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)