0
0
Fork 0
mirror of https://github.com/matrix-org/dendrite synced 2024-12-14 06:43:49 +01:00

mediaapi/writers: Minor improvements to comments

This commit is contained in:
Robert Swain 2017-05-26 10:03:16 +02:00
parent a3aaa86ea3
commit 2fa0ae29d7
2 changed files with 3 additions and 4 deletions

View file

@ -78,7 +78,6 @@ func (r *downloadRequest) jsonErrorResponse(w http.ResponseWriter, res util.JSON
// Validate validates the downloadRequest fields // Validate validates the downloadRequest fields
func (r *downloadRequest) Validate() *util.JSONResponse { func (r *downloadRequest) Validate() *util.JSONResponse {
// FIXME: the following errors aren't bad JSON, rather just a bad request path
// maybe give the URL pattern in the routing, these are not even possible as the handler would not be hit...? // maybe give the URL pattern in the routing, these are not even possible as the handler would not be hit...?
if r.MediaMetadata.MediaID == "" { if r.MediaMetadata.MediaID == "" {
return &util.JSONResponse{ return &util.JSONResponse{

View file

@ -35,13 +35,13 @@ type uploadRequest struct {
Logger *log.Entry Logger *log.Entry
} }
// uploadResponse defines the format of the JSON response
// https://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-media-r0-upload // https://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-media-r0-upload
type uploadResponse struct { type uploadResponse struct {
ContentURI string `json:"content_uri"` ContentURI string `json:"content_uri"`
} }
// Upload implements /upload // Upload implements /upload
//
// This endpoint involves uploading potentially significant amounts of data to the homeserver. // This endpoint involves uploading potentially significant amounts of data to the homeserver.
// 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. // 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. // Uploaded files are processed piece-wise to avoid DoS attacks which would starve the server of memory.
@ -63,8 +63,8 @@ func Upload(req *http.Request, cfg *config.MediaAPI) util.JSONResponse {
} }
// parseAndValidateRequest parses the incoming upload request to validate and extract // parseAndValidateRequest parses the incoming upload request to validate and extract
// all the metadata about the media being uploaded. Returns either an uploadRequest or // all the metadata about the media being uploaded.
// an error formatted as a util.JSONResponse // Returns either an uploadRequest or an error formatted as a util.JSONResponse
func parseAndValidateRequest(req *http.Request, cfg *config.MediaAPI) (*uploadRequest, *util.JSONResponse) { func parseAndValidateRequest(req *http.Request, cfg *config.MediaAPI) (*uploadRequest, *util.JSONResponse) {
if req.Method != "POST" { if req.Method != "POST" {
return nil, &util.JSONResponse{ return nil, &util.JSONResponse{