mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-07 23:13:11 -06:00
mediaapi/routing: Rename Fudge to downloadRequestHandler
This commit is contained in:
parent
81706408bd
commit
0a24e406af
|
|
@ -34,13 +34,13 @@ type contextKeys string
|
||||||
const ctxValueLogger = contextKeys("logger")
|
const ctxValueLogger = contextKeys("logger")
|
||||||
const ctxValueRequestID = contextKeys("requestid")
|
const ctxValueRequestID = contextKeys("requestid")
|
||||||
|
|
||||||
type Fudge struct {
|
type downloadRequestHandler struct {
|
||||||
Config config.MediaAPI
|
Config config.MediaAPI
|
||||||
Database *storage.Database
|
Database *storage.Database
|
||||||
DownloadServer writers.DownloadServer
|
DownloadServer writers.DownloadServer
|
||||||
}
|
}
|
||||||
|
|
||||||
func (fudge Fudge) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
func (handler downloadRequestHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
||||||
// NOTE: The code below is from util.Protect and respond but this is the only
|
// NOTE: The code below is from util.Protect and respond but this is the only
|
||||||
// API that needs a different form of it to be able to pass the
|
// API that needs a different form of it to be able to pass the
|
||||||
// http.ResponseWriter to the handler
|
// http.ResponseWriter to the handler
|
||||||
|
|
@ -68,7 +68,7 @@ func (fudge Fudge) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
||||||
w.Header().Set("Content-Type", "application/json")
|
w.Header().Set("Content-Type", "application/json")
|
||||||
|
|
||||||
vars := mux.Vars(req)
|
vars := mux.Vars(req)
|
||||||
writers.Download(w, req, vars["serverName"], vars["mediaId"], fudge.Config, fudge.Database, fudge.DownloadServer)
|
writers.Download(w, req, vars["serverName"], vars["mediaId"], handler.Config, handler.Database, handler.DownloadServer)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Setup registers HTTP handlers with the given ServeMux. It also supplies the given http.Client
|
// Setup registers HTTP handlers with the given ServeMux. It also supplies the given http.Client
|
||||||
|
|
@ -85,14 +85,14 @@ func Setup(servMux *http.ServeMux, httpClient *http.Client, cfg config.MediaAPI,
|
||||||
LocalServerName: cfg.ServerName,
|
LocalServerName: cfg.ServerName,
|
||||||
}
|
}
|
||||||
|
|
||||||
fudge := Fudge{
|
handler := downloadRequestHandler{
|
||||||
Config: cfg,
|
Config: cfg,
|
||||||
Database: db,
|
Database: db,
|
||||||
DownloadServer: downloadServer,
|
DownloadServer: downloadServer,
|
||||||
}
|
}
|
||||||
|
|
||||||
r0mux.Handle("/download/{serverName}/{mediaId}",
|
r0mux.Handle("/download/{serverName}/{mediaId}",
|
||||||
prometheus.InstrumentHandler("download", fudge),
|
prometheus.InstrumentHandler("download", handler),
|
||||||
)
|
)
|
||||||
|
|
||||||
servMux.Handle("/metrics", prometheus.Handler())
|
servMux.Handle("/metrics", prometheus.Handler())
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue