fmt.Printf("Starting Armadillo on port %d with root:\n %v\n",
configuration.Port, configuration.JailRoot)
server.SetConfig(configuration)
- server.RunBackEnd(configuration)
+ server.RunBackEnd()
}
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)
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"))
}
}
-func RunBackEnd(config *config.Configuration) {
+func RunBackEnd() {
mux := http.NewServeMux()
mux.HandleFunc("/", indexHandler)
mux.Handle("/fe/", http.StripPrefix("/fe/", http.FileServer(http.Dir(kFrontEndFiles))))
mux.HandleFunc("/download", downloadHandler)
mux.HandleFunc("/proxy", proxyHandler)
- gConfig = config
-
error := http.ListenAndServe(fmt.Sprintf(":%d", config.Port), mux)
fmt.Printf("error %v", error)
}