Config now only need be declared once in package server
authorRobert Sesek <rsesek@bluestatic.org>
Tue, 3 Apr 2012 13:10:24 +0000 (09:10 -0400)
committerRobert Sesek <rsesek@bluestatic.org>
Tue, 3 Apr 2012 13:32:06 +0000 (09:32 -0400)
main.go
server/paths.go
server/server.go

diff --git a/main.go b/main.go
index 5fe6ef43cd9eb93505329b36492eb52a95cf6e24..8109fd53b39f90c78c79338d23699b9c370f3744 100644 (file)
--- a/main.go
+++ b/main.go
@@ -54,5 +54,5 @@ func main() {
        fmt.Printf("Starting Armadillo on port %d with root:\n  %v\n",
                configuration.Port, configuration.JailRoot)
        server.SetConfig(configuration)
-       server.RunBackEnd(configuration)
+       server.RunBackEnd()
 }
index ee46174b6dcf7e88e60bf47fbe1858438d276dd6..ae084fb38b07c1311efab7a7053850b84d2813d0 100644 (file)
 package server
 
 import (
-       "../config"
        "errors"
        "os"
        "path"
        "strings"
 )
 
-var gConfig *config.Configuration
-
-func SetConfig(aConfig *config.Configuration) {
-       gConfig = aConfig
-}
-
 func canonicalizePath(raw_path string) string {
        raw_path = path.Join(gConfig.JailRoot, raw_path)
        return path.Clean(raw_path)
index d5082908cfac056cfd206ee49aa1cc71cfd403c6..db101aba3bbc79c3df60e44ed31f05984bc30b7a 100644 (file)
@@ -25,7 +25,11 @@ import (
 
 var dir, file = path.Split(path.Clean(os.Getenv("_")))
 var kFrontEndFiles string = path.Join(dir, "fe")
-var gConfig *config.Configuration = nil
+var gConfig *config.Configuration
+
+func SetConfig(aConfig *config.Configuration) {
+       gConfig = aConfig
+}
 
 func indexHandler(response http.ResponseWriter, request *http.Request) {
        fd, err := os.Open(path.Join(kFrontEndFiles, "index.html"))
@@ -197,7 +201,7 @@ func okResponse(response http.ResponseWriter, data interface{}) {
        }
 }
 
-func RunBackEnd(config *config.Configuration) {
+func RunBackEnd() {
        mux := http.NewServeMux()
        mux.HandleFunc("/", indexHandler)
        mux.Handle("/fe/", http.StripPrefix("/fe/", http.FileServer(http.Dir(kFrontEndFiles))))
@@ -205,8 +209,6 @@ func RunBackEnd(config *config.Configuration) {
        mux.HandleFunc("/download", downloadHandler)
        mux.HandleFunc("/proxy", proxyHandler)
 
-       gConfig = config
-
        error := http.ListenAndServe(fmt.Sprintf(":%d", config.Port), mux)
        fmt.Printf("error %v", error)
 }