From 4676ef2d971204064a8a5ef7d3618b542a87a790 Mon Sep 17 00:00:00 2001 From: Markus Grüneis Date: Sun, 19 Oct 2014 16:43:01 +0200 Subject: hub: use goji for new s5srvWeb --- src/hub/Makefile | 1 + src/hub/src/spreadspace.org/sfive-hub/s5hub.go | 6 ++++++ src/hub/src/spreadspace.org/sfive/s5srvWeb.go | 18 ++++++++++++++++++ 3 files changed, 25 insertions(+) create mode 100644 src/hub/src/spreadspace.org/sfive/s5srvWeb.go (limited to 'src') diff --git a/src/hub/Makefile b/src/hub/Makefile index 317615a..1c4878b 100644 --- a/src/hub/Makefile +++ b/src/hub/Makefile @@ -5,6 +5,7 @@ getlibs: export GOPATH=$(curdir) getlibs: $(GOCMD) get "github.com/coopernurse/gorp" $(GOCMD) get "github.com/mattn/go-sqlite3" + $(GOCMD) get "github.com/zenazn/goji" build: export GOPATH=$(curdir) build: getlibs diff --git a/src/hub/src/spreadspace.org/sfive-hub/s5hub.go b/src/hub/src/spreadspace.org/sfive-hub/s5hub.go index c1802eb..bb5e80f 100644 --- a/src/hub/src/spreadspace.org/sfive-hub/s5hub.go +++ b/src/hub/src/spreadspace.org/sfive-hub/s5hub.go @@ -23,5 +23,11 @@ func main() { server.ServePipe("/run/sfive/pipe") }() + wg.Add(1) + go func() { + defer wg.Done() + server.ServeWeb() + }() + wg.Wait() } diff --git a/src/hub/src/spreadspace.org/sfive/s5srvWeb.go b/src/hub/src/spreadspace.org/sfive/s5srvWeb.go new file mode 100644 index 0000000..1b64c4b --- /dev/null +++ b/src/hub/src/spreadspace.org/sfive/s5srvWeb.go @@ -0,0 +1,18 @@ +package sfive + +import ( + "fmt" + "net/http" + + "github.com/zenazn/goji" + "github.com/zenazn/goji/web" +) + +func hello(c web.C, w http.ResponseWriter, r *http.Request) { + fmt.Fprintf(w, "Hello, %s!", c.URLParams["name"]) +} + +func (self StatsSinkServer) ServeWeb() { + goji.Get("/hello/:name", hello) + goji.Serve() +} -- cgit v1.2.3