From d46746399cca5b617dca75f68d909435d8a6205a Mon Sep 17 00:00:00 2001 From: Joel Collins Date: Mon, 22 Jun 2020 17:31:12 +0100 Subject: [PATCH] Fixed automatic marshalling --- src/labthings/server/view/__init__.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/labthings/server/view/__init__.py b/src/labthings/server/view/__init__.py index ec6d8093..7d6c5cf8 100644 --- a/src/labthings/server/view/__init__.py +++ b/src/labthings/server/view/__init__.py @@ -90,6 +90,10 @@ def dispatch_request(self, *args, **kwargs): if meth is None and request.method == "HEAD": meth = getattr(self, "get", None) + # Marhal response if a response schema is defines + if self.get_schema(): + meth = marshal_with(self.get_schema())(meth) + # Flask should ensure this is assersion never fails assert meth is not None, f"Unimplemented method {request.method!r}" @@ -193,10 +197,6 @@ def dispatch_request(self, *args, **kwargs): if request.method in ("POST", "PUT", "PATCH") and self.get_args(): meth = use_args(self.get_args())(meth) - # Marhal response if a response schema is defines - if self.get_schema(): - meth = marshal_with(self.get_schema())(meth) - # Generate basic response resp = self.represent_response(meth(*args, **kwargs))