Skip to content

Commit

Permalink
Fixed automatic marshalling
Browse files Browse the repository at this point in the history
  • Loading branch information
Joel Collins committed Jun 22, 2020
1 parent f5e7e35 commit d467463
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/labthings/server/view/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}"

Expand Down Expand Up @@ -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))

Expand Down

0 comments on commit d467463

Please sign in to comment.