diff options
author | Jakob Borg <jakob@nym.se> | 2014-03-26 20:41:00 +0100 |
---|---|---|
committer | Jakob Borg <jakob@nym.se> | 2014-03-26 20:41:00 +0100 |
commit | e37441627f21a7ea6d5fee909a2f40fe64e6ee99 (patch) | |
tree | 7efb312152e0990c5f138dc3a1bdaca6f746adf0 | |
parent | bcd3fd40e4158ec1aef982435729919c5c6e4472 (diff) | |
parent | f4c6cd1676cf2a7dc3a4aff5398c7162df4b80cf (diff) |
Merge pull request #104 from filoozom/patch-2
Set cache control on /rest/* (fixes #95)
-rw-r--r-- | cmd/syncthing/gui.go | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/cmd/syncthing/gui.go b/cmd/syncthing/gui.go index e25508b383..53d9f01ae5 100644 --- a/cmd/syncthing/gui.go +++ b/cmd/syncthing/gui.go @@ -44,6 +44,7 @@ func startGUI(addr string, m *Model) { mr := martini.New() mr.Use(embeddedStatic()) mr.Use(martini.Recovery()) + mr.Use(restMiddleware) mr.Action(router.Handle) mr.Map(m) err := http.ListenAndServe(addr, mr) @@ -57,6 +58,12 @@ func getRoot(w http.ResponseWriter, r *http.Request) { http.Redirect(w, r, "/index.html", 302) } +func restMiddleware(w http.ResponseWriter, r *http.Request) { + if len(r.URL.Path) >= 6 && r.URL.Path[:6] == "/rest/" { + w.Header().Set("Cache-Control", "no-cache") + } +} + func restGetVersion() string { return Version } |