Closed Jaymon closed 3 years ago
Turns out, order matters, while the above didn't work, this did:
class Default(Controller):
@route(lambda req: "foo" in req.kwargs)
@param('foo')
def POST_foo(self, **kwargs):
pout.v(req)
return {}
@route(lambda req: "foo" not in req.kwargs)
@param('bar')
@param('che')
def POST_no_foo(self, **kwargs):
pout.v(req)
return {}
Notice that @route
is now the first decorator, or farthest from the actual handle method. What was happening is POST_foo
would fail because foo
wasn't an argument, so a 400 response was returned because it was missing a parameter.
I expected POSTing with
foo
would go toPOST_foo
and POSTing withoutfoo
would go toPOST_no_foo
but everything was going toPOST_no_foo
, I'm not sure why.