mirror of
https://github.com/octoleo/syncthing.git
synced 2025-01-03 15:17:25 +00:00
Set cache control on /rest/* (fixes #95)
Disable caching for all /rest/* requests.
This commit is contained in:
parent
bcd3fd40e4
commit
f4c6cd1676
@ -44,6 +44,7 @@ func startGUI(addr string, m *Model) {
|
|||||||
mr := martini.New()
|
mr := martini.New()
|
||||||
mr.Use(embeddedStatic())
|
mr.Use(embeddedStatic())
|
||||||
mr.Use(martini.Recovery())
|
mr.Use(martini.Recovery())
|
||||||
|
mr.Use(restMiddleware)
|
||||||
mr.Action(router.Handle)
|
mr.Action(router.Handle)
|
||||||
mr.Map(m)
|
mr.Map(m)
|
||||||
err := http.ListenAndServe(addr, mr)
|
err := http.ListenAndServe(addr, mr)
|
||||||
@ -57,6 +58,12 @@ func getRoot(w http.ResponseWriter, r *http.Request) {
|
|||||||
http.Redirect(w, r, "/index.html", 302)
|
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 {
|
func restGetVersion() string {
|
||||||
return Version
|
return Version
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user