mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-07 06:53:09 -06:00
mediaapi/routing: Pass pointer to config struct instead of copying
This commit is contained in:
parent
a821b9155f
commit
937162a722
|
|
@ -39,7 +39,7 @@ func main() {
|
|||
log.Panic("No BIND_ADDRESS environment variable found.")
|
||||
}
|
||||
|
||||
cfg := config.MediaAPI{
|
||||
cfg := &config.MediaAPI{
|
||||
ServerName: "localhost",
|
||||
BasePath: "/Users/robertsw/dendrite",
|
||||
MaxFileSize: 10 * 1024 * 1024,
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ const pathPrefixR0 = "/_matrix/media/v1"
|
|||
|
||||
// Setup registers HTTP handlers with the given ServeMux. It also supplies the given http.Client
|
||||
// to clients which need to make outbound HTTP requests.
|
||||
func Setup(servMux *http.ServeMux, httpClient *http.Client, cfg config.MediaAPI, db *storage.Database) {
|
||||
func Setup(servMux *http.ServeMux, httpClient *http.Client, cfg *config.MediaAPI, db *storage.Database) {
|
||||
apiMux := mux.NewRouter()
|
||||
r0mux := apiMux.PathPrefix(pathPrefixR0).Subrouter()
|
||||
r0mux.Handle("/upload", make("upload", util.NewJSONRequestHandler(func(req *http.Request) util.JSONResponse {
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ var nTries = 5
|
|||
// If they are present in the cache, they are served directly.
|
||||
// If they are not present in the cache, they are obtained from the remote server and
|
||||
// simultaneously served back to the client and written into the cache.
|
||||
func Download(w http.ResponseWriter, req *http.Request, origin types.ServerName, mediaID types.MediaID, cfg config.MediaAPI, db *storage.Database, activeRemoteRequests *types.ActiveRemoteRequests) {
|
||||
func Download(w http.ResponseWriter, req *http.Request, origin types.ServerName, mediaID types.MediaID, cfg *config.MediaAPI, db *storage.Database, activeRemoteRequests *types.ActiveRemoteRequests) {
|
||||
logger := util.GetLogger(req.Context())
|
||||
|
||||
// request validation
|
||||
|
|
|
|||
|
|
@ -100,7 +100,7 @@ type uploadResponse struct {
|
|||
// This implementation supports a configurable maximum file size limit in bytes. If a user tries to upload more than this, they will receive an error that their upload is too large.
|
||||
// Uploaded files are processed piece-wise to avoid DoS attacks which would starve the server of memory.
|
||||
// TODO: Requests time out if they have not received any data within the configured timeout period.
|
||||
func Upload(req *http.Request, cfg config.MediaAPI, db *storage.Database) util.JSONResponse {
|
||||
func Upload(req *http.Request, cfg *config.MediaAPI, db *storage.Database) util.JSONResponse {
|
||||
logger := util.GetLogger(req.Context())
|
||||
|
||||
if req.Method != "POST" {
|
||||
|
|
|
|||
Loading…
Reference in a new issue