Handle URLs with an extraneous /backend/ prefix (#1)

* handle /backend in URLs as speedtest_worker.js is set up to do so

* fixed dropped slashes
This commit is contained in:
Fazal Majid 2020-06-08 04:43:51 +01:00 committed by GitHub
parent 30c56a0d46
commit 8971ba8117
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -47,19 +47,31 @@ func ListenAndServe(conf *config.Config) error {
log.Infof("Starting backend server on %s", net.JoinHostPort(conf.BindAddress, conf.Port))
r.Get("/*", pages)
r.HandleFunc("/empty", empty)
r.HandleFunc("/backend/empty", empty)
r.Get("/garbage", garbage)
r.Get("/backend/garbage", garbage)
r.Get("/getIP", getIP)
r.Get("/backend/getIP", getIP)
r.Get("/results", results.DrawPNG)
r.Get("/results/", results.DrawPNG)
r.Get("/backend/results", results.DrawPNG)
r.Get("/backend/results/", results.DrawPNG)
r.Post("/results/telemetry", results.Record)
r.Post("/backend/results/telemetry", results.Record)
r.HandleFunc("/stats", results.Stats)
r.HandleFunc("/backend/stats", results.Stats)
// PHP frontend default values compatibility
r.HandleFunc("/empty.php", empty)
r.HandleFunc("/backend/empty.php", empty)
r.Get("/garbage.php", garbage)
r.Get("/backend/garbage.php", garbage)
r.Get("/getIP.php", getIP)
r.Get("/backend/getIP.php", getIP)
r.Post("/results/telemetry.php", results.Record)
r.Post("/backend/results/telemetry.php", results.Record)
r.HandleFunc("/stats.php", results.Stats)
r.HandleFunc("/backend/stats.php", results.Stats)
return http.ListenAndServe(net.JoinHostPort(conf.BindAddress, conf.Port), r)
}