lightwalletd/common/downloadhandler.go

46 lines
1.1 KiB
Go
Raw Normal View History

2020-05-04 12:17:14 -07:00
package common
import (
"net/http"
"strings"
2020-05-13 19:23:53 -07:00
"github.com/sirupsen/logrus"
2020-05-04 12:17:14 -07:00
)
// Handle http(s) downloads for zcash params
func ParamsHandler(w http.ResponseWriter, req *http.Request) {
2020-05-04 12:17:14 -07:00
if strings.HasSuffix(req.URL.Path, "sapling-output.params") {
Metrics.TotalSaplingParamsCounter.Inc()
Log.WithFields(logrus.Fields{
2020-05-13 19:23:53 -07:00
"method": "params",
"param": "sapling-output",
}).Info("ParamsHandler")
http.Redirect(w, req, "https://z.cash/downloads/sapling-output.params", http.StatusMovedPermanently)
2020-05-04 12:17:14 -07:00
return
}
if strings.HasSuffix(req.URL.Path, "sapling-spend.params") {
Log.WithFields(logrus.Fields{
2020-05-13 19:23:53 -07:00
"method": "params",
"param": "sapling-spend",
}).Info("ParamsHandler")
http.Redirect(w, req, "https://z.cash/downloads/sapling-spend.params", http.StatusMovedPermanently)
2020-05-04 12:17:14 -07:00
return
}
if strings.HasSuffix(req.URL.Path, "sprout-groth16.params") {
Log.WithFields(logrus.Fields{
2020-05-13 19:23:53 -07:00
"method": "params",
"param": "sprout",
}).Info("ParamsHandler")
Metrics.TotalSproutParamsCounter.Inc()
2020-05-13 19:23:53 -07:00
http.Redirect(w, req, "https://z.cash/downloads/sprout-groth16.params", http.StatusMovedPermanently)
2020-05-04 12:17:14 -07:00
return
}
http.Error(w, "Not Found", 404)
}