aboutsummaryrefslogtreecommitdiffstats
path: root/web/src/js/backends/static.js
diff options
context:
space:
mode:
authorMaximilian Hils <git@maximilianhils.com>2017-08-08 16:59:07 +0200
committerGitHub <noreply@github.com>2017-08-08 16:59:07 +0200
commit802e8cb34105ac7464838fc57ba2294428f9d3c2 (patch)
treed9e2105735789eec5b6eb04c3d1cdc9fc336d819 /web/src/js/backends/static.js
parent6d9b5b0c062126d2ac47fa50795c7d560321e0f7 (diff)
parent0ad552ead46ae501b8af0a28820aad40b927cba7 (diff)
downloadmitmproxy-802e8cb34105ac7464838fc57ba2294428f9d3c2.tar.gz
mitmproxy-802e8cb34105ac7464838fc57ba2294428f9d3c2.tar.bz2
mitmproxy-802e8cb34105ac7464838fc57ba2294428f9d3c2.zip
Merge pull request #2504 from MatthewShao/static-viewer
[WIP] [web] Static viewer for mitmweb
Diffstat (limited to 'web/src/js/backends/static.js')
-rw-r--r--web/src/js/backends/static.js33
1 files changed, 33 insertions, 0 deletions
diff --git a/web/src/js/backends/static.js b/web/src/js/backends/static.js
new file mode 100644
index 00000000..6657fecf
--- /dev/null
+++ b/web/src/js/backends/static.js
@@ -0,0 +1,33 @@
+/*
+ * This backend uses the REST API only to host static instances,
+ * without any Websocket connection.
+ */
+import { fetchApi } from "../utils"
+
+export default class StaticBackend {
+ constructor(store) {
+ this.store = store
+ this.onOpen()
+ }
+
+ onOpen() {
+ this.fetchData("settings")
+ this.fetchData("flows")
+ this.fetchData("events")
+ this.fetchData("options")
+ }
+
+ fetchData(resource) {
+ fetchApi(`/${resource}`)
+ .then(res => res.json())
+ .then(json => {
+ this.receive(resource, json)
+ })
+ }
+
+ receive(resource, data) {
+ let type = `${resource}_RECEIVE`.toUpperCase()
+ this.store.dispatch({ type, cmd: "receive", resource, data })
+ }
+
+}