diff options
author | Markus Grüneis <gimpf@gimpf.org> | 2014-10-23 13:24:04 +0200 |
---|---|---|
committer | Markus Grüneis <gimpf@gimpf.org> | 2014-10-23 13:24:04 +0200 |
commit | 4717ba0aae3d2cb7fed370ee55fc6e6841def315 (patch) | |
tree | a208fb507ea3055ff0925b88830a517ed363fa98 /src/hub/src | |
parent | hub: fix filtered queries, remove unused functions (diff) |
hub: serve viz app under /viz
Diffstat (limited to 'src/hub/src')
-rw-r--r-- | src/hub/src/spreadspace.org/sfive-hub/s5hub.go | 3 | ||||
-rw-r--r-- | src/hub/src/spreadspace.org/sfive/s5srvWeb.go | 13 |
2 files changed, 14 insertions, 2 deletions
diff --git a/src/hub/src/spreadspace.org/sfive-hub/s5hub.go b/src/hub/src/spreadspace.org/sfive-hub/s5hub.go index 3f41fea..2509139 100644 --- a/src/hub/src/spreadspace.org/sfive-hub/s5hub.go +++ b/src/hub/src/spreadspace.org/sfive-hub/s5hub.go @@ -19,6 +19,7 @@ func main() { startGramPipe := flag.Bool("start-pipegram-server", true, "start a datagram oriented pipe server; see option pipegram") startWeb := flag.Bool("start-web-server", true, "start a webserver") forward := flag.String("forward-url", "", "forward to another sfive-server with http server at base-url") + vizAppDir := flag.String("viz-dir", "./viz", "base-path to the viz application") flag.Parse() @@ -56,7 +57,7 @@ func main() { go func() { defer wg.Done() s5hl.Println("start web-srv") - server.ServeWeb() + server.ServeWeb(*vizAppDir) s5hl.Println("web finished") }() } diff --git a/src/hub/src/spreadspace.org/sfive/s5srvWeb.go b/src/hub/src/spreadspace.org/sfive/s5srvWeb.go index 7adbb81..31964ad 100644 --- a/src/hub/src/spreadspace.org/sfive/s5srvWeb.go +++ b/src/hub/src/spreadspace.org/sfive/s5srvWeb.go @@ -5,6 +5,7 @@ import ( "fmt" "io/ioutil" "net/http" + "os" "strconv" "time" @@ -180,7 +181,15 @@ func (self StatsSinkServer) getStats(c web.C, w http.ResponseWriter, r *http.Req fmt.Fprintf(w, "%s", jsonString) } -func (self StatsSinkServer) ServeWeb() { +func (self StatsSinkServer) ServeWeb(vizAppLocation string) { + if _, err := os.Stat(vizAppLocation); err != nil { + if os.IsNotExist(err) { + s5l.Panicf("web: viz-app at %s does not exist.", vizAppLocation) + } else { + s5l.Printf("web: failed to stat %s: %v", vizAppLocation, err) + } + } + goji.Get("/hello/:name", hello) goji.Get("/tags", self.getTagList) goji.Get("/sources", self.getSourcesList) @@ -189,5 +198,7 @@ func (self StatsSinkServer) ServeWeb() { goji.Get("/updates/:id", self.getUpdate) goji.Post("/updates", self.postUpdate) goji.Get("/stats", self.getStats) + goji.Handle("/viz/*", http.StripPrefix("/viz/", http.FileServer(http.Dir(vizAppLocation)))) + goji.Serve() } |