diff options
author | Mark Haines <mark.haines@matrix.org> | 2015-04-21 16:35:53 +0100 |
---|---|---|
committer | Mark Haines <mark.haines@matrix.org> | 2015-04-21 16:35:53 +0100 |
commit | 1967650bc4cbeea3deacaf540036f9cae4cbc330 (patch) | |
tree | ecd37093f9be6a25b2957ce31c6ebe9895f493f1 /synapse/rest/media/v1/download_resource.py | |
parent | Split out the JsonResource request logging and error handling into a separate... (diff) | |
download | synapse-1967650bc4cbeea3deacaf540036f9cae4cbc330.tar.xz |
Combine the request wrappers in rest/media/v1 and http/server into a single wrapper decorator
Diffstat (limited to 'synapse/rest/media/v1/download_resource.py')
-rw-r--r-- | synapse/rest/media/v1/download_resource.py | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/synapse/rest/media/v1/download_resource.py b/synapse/rest/media/v1/download_resource.py index c585bb11f7..0fe6abf647 100644 --- a/synapse/rest/media/v1/download_resource.py +++ b/synapse/rest/media/v1/download_resource.py @@ -13,7 +13,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -from .base_resource import BaseMediaResource +from .base_resource import BaseMediaResource, parse_media_id +from synapse.http.server import request_handler from twisted.web.server import NOT_DONE_YET from twisted.internet import defer @@ -28,15 +29,10 @@ class DownloadResource(BaseMediaResource): self._async_render_GET(request) return NOT_DONE_YET - @BaseMediaResource.catch_errors + @request_handler @defer.inlineCallbacks def _async_render_GET(self, request): - try: - server_name, media_id = request.postpath - except: - self._respond_404(request) - return - + server_name, media_id = parse_media_id(request) if server_name == self.server_name: yield self._respond_local_file(request, media_id) else: |