summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--dat/sample-post.json9
-rw-r--r--src/hub/src/spreadspace.org/sfive/s5srvWeb.go20
-rwxr-xr-xsrc/hub/test-client10
3 files changed, 36 insertions, 3 deletions
diff --git a/dat/sample-post.json b/dat/sample-post.json
new file mode 100644
index 0000000..35c76e0
--- /dev/null
+++ b/dat/sample-post.json
@@ -0,0 +1,9 @@
+{
+ "streamer-id": {"quality": "high", "content-id": "av", "format": "webm"},
+ "hostname": "localhost",
+ "tags": ["suppa", "toll"],
+ "version": 1,
+ "data": {"bytes-sent": 1519, "client-count": 0},
+ "start-time": "2013-10-21T12:30:00Z",
+ "duration-ms": 300000
+}
diff --git a/src/hub/src/spreadspace.org/sfive/s5srvWeb.go b/src/hub/src/spreadspace.org/sfive/s5srvWeb.go
index 0aa1426..d2367fa 100644
--- a/src/hub/src/spreadspace.org/sfive/s5srvWeb.go
+++ b/src/hub/src/spreadspace.org/sfive/s5srvWeb.go
@@ -3,6 +3,7 @@ package sfive
import (
"encoding/json"
"fmt"
+ "io/ioutil"
"net/http"
"strconv"
"time"
@@ -91,6 +92,24 @@ func (self StatsSinkServer) getUpdate(c web.C, w http.ResponseWriter, r *http.Re
}
}
+func (self StatsSinkServer) postUpdate(c web.C, w http.ResponseWriter, r *http.Request) {
+ decoder := NewPlainDecoder()
+
+ buffer, err := ioutil.ReadAll(r.Body)
+ if err != nil {
+ s5l.Printf("web: failed to read post value: %v\n", err)
+ return
+ }
+
+ data, err := decoder.Decode(buffer)
+ if err != nil {
+ s5l.Printf("web: failed to decode: %v\ndat:%v", err, string(buffer))
+ return
+ }
+
+ self.appendData <- data
+}
+
func (self StatsSinkServer) getStats(c web.C, w http.ResponseWriter, r *http.Request) {
filter := getFilter(r)
stats, err := self.store.GetStats(&filter)
@@ -116,6 +135,7 @@ func (self StatsSinkServer) ServeWeb() {
goji.Get("/sources/:id", self.getSource)
goji.Get("/updates", self.getUpdateList)
goji.Get("/updates/:id", self.getUpdate)
+ goji.Post("/updates", self.postUpdate)
goji.Get("/stats", self.getStats)
goji.Serve()
}
diff --git a/src/hub/test-client b/src/hub/test-client
index c9d7b91..0696bc5 100755
--- a/src/hub/test-client
+++ b/src/hub/test-client
@@ -1,8 +1,12 @@
#!/bin/sh
echo import sample.json
-time socat file:../../dat/sample.json,rdonly unix-client:/run/sfive/pipe
-
+socat file:../../dat/sample.json,rdonly unix-client:/run/sfive/pipe
echo show query result
-wget -q -S -O - 'http://localhost:8000/updates?from=2013-10-24T05:00:00Z&to=2013-10-24T00:05:20Z
+wget -q -S -O - 'http://localhost:8000/updates?from=2013-10-24T05:00:00Z&to=2013-10-24T00:05:20Z'
+
+echo '\npost update'
+wget --post-file='../../dat/sample-post.json' 'http://localhost:8000/updates'
+
+echo '\ndone'