summaryrefslogtreecommitdiff
path: root/src/hub
diff options
context:
space:
mode:
authorChristian Pointner <equinox@spreadspace.org>2017-11-16 22:38:37 +0100
committerChristian Pointner <equinox@spreadspace.org>2017-11-16 22:38:37 +0100
commit25a6c9dd08d01fa24b769d3b12a68ac6418077a0 (patch)
tree5addddd460f2bc889e28fec31b5092acb169e420 /src/hub
parentMerge branch 'clean-shutdown' (diff)
move hub web api to /api/v1/ path
Diffstat (limited to 'src/hub')
-rw-r--r--src/hub/src/spreadspace.org/sfive/s5srvForward.go4
-rw-r--r--src/hub/src/spreadspace.org/sfive/s5srvWeb.go16
-rwxr-xr-xsrc/hub/test-client6
3 files changed, 14 insertions, 12 deletions
diff --git a/src/hub/src/spreadspace.org/sfive/s5srvForward.go b/src/hub/src/spreadspace.org/sfive/s5srvForward.go
index 904dc18..9e395be 100644
--- a/src/hub/src/spreadspace.org/sfive/s5srvForward.go
+++ b/src/hub/src/spreadspace.org/sfive/s5srvForward.go
@@ -54,7 +54,7 @@ func fwdGetLastUpdateID(baseUrl string, client *http.Client, hubUUID string) (la
lastID = -1
var resp *http.Response
- resp, err = client.Get(baseUrl + "/lastupdate/" + hubUUID)
+ resp, err = client.Get(baseUrl + "/api/v1/lastupdate/" + hubUUID)
if err != nil {
s5l.Printf("srv|fwd: querying for lastupdate failed: %v", err)
return
@@ -110,7 +110,7 @@ func fwdPostUpdates(client *http.Client, url string, pr *io.PipeReader) (int, er
}
func (srv *Server) forwardRun(baseUrl string, client *http.Client) {
- url := baseUrl + "/updates/_bulk"
+ url := baseUrl + "/api/v1/updates/_bulk"
hubUUID := srv.store.GetHubUUID()
tryResync:
for {
diff --git a/src/hub/src/spreadspace.org/sfive/s5srvWeb.go b/src/hub/src/spreadspace.org/sfive/s5srvWeb.go
index 65e677a..54f1d18 100644
--- a/src/hub/src/spreadspace.org/sfive/s5srvWeb.go
+++ b/src/hub/src/spreadspace.org/sfive/s5srvWeb.go
@@ -419,14 +419,16 @@ func (srv *Server) ServeWeb(cfg WebInterfaceConfig) error {
s5l.Printf("srv|web: listening on '%s'", cfg.ListenAddr)
mux := http.NewServeMux()
+
+ mux.Handle("/api/v1/hubs", http.StripPrefix("/api/v1", webHandler{srv, webHubs}))
+ mux.Handle("/api/v1/sources", http.StripPrefix("/api/v1", webHandler{srv, webSources}))
+ mux.Handle("/api/v1/clients", http.StripPrefix("/api/v1", webHandler{srv, webClients}))
+ mux.Handle("/api/v1/updates/", http.StripPrefix("/api/v1", webHandler{srv, webUpdatesWithParam}))
+ mux.Handle("/api/v1/updates", http.StripPrefix("/api/v1", webHandler{srv, webUpdates}))
+ mux.Handle("/api/v1/lastupdate/", http.StripPrefix("/api/v1", webHandler{srv, webLastUpdateIDForUUID}))
+ mux.Handle("/api/v1/lastupdate", http.StripPrefix("/api/v1", webHandler{srv, webLastUpdateID}))
+
mux.Handle("/healthz", webHandler{srv, webHealthz})
- mux.Handle("/hubs", webHandler{srv, webHubs})
- mux.Handle("/sources", webHandler{srv, webSources})
- mux.Handle("/clients", webHandler{srv, webClients})
- mux.Handle("/updates/", webHandler{srv, webUpdatesWithParam})
- mux.Handle("/updates", webHandler{srv, webUpdates})
- mux.Handle("/lastupdate/", webHandler{srv, webLastUpdateIDForUUID})
- mux.Handle("/lastupdate", webHandler{srv, webLastUpdateID})
// mux.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.Dir( ..staticDir.. ))))
mux.Handle("/", webHandler{srv, webNotFound})
diff --git a/src/hub/test-client b/src/hub/test-client
index 620d9a4..0e3424e 100755
--- a/src/hub/test-client
+++ b/src/hub/test-client
@@ -18,18 +18,18 @@ case $1 in
web)
echo "web: post sample-web.json"
echo "-------------------------"
- time curl 'http://localhost:8000/updates' -d @../../dat/sample-web.json
+ time curl 'http://localhost:8000/api/v1/updates' -d @../../dat/sample-web.json
echo ""
;;
web-bulk)
echo "web: post sample-web-bulk.json"
echo "------------------------------"
- time curl 'http://localhost:8000/updates/_bulk' -d @../../dat/sample-web-bulk.json
+ time curl 'http://localhost:8000/api/v1/updates/_bulk' -d @../../dat/sample-web-bulk.json
echo ""
;;
esac
echo "store contents"
echo "--------------"
-curl 'http://localhost:8000/updates/_bulk' | jq .
+curl 'http://localhost:8000/api/v1/updates/_bulk' | jq .
echo ""