add __repr__ for sanic request

This commit is contained in:
huyuhan 2017-09-15 18:34:56 +08:00
parent 9fb8bec715
commit 12dafd07b8

View File

@ -68,6 +68,11 @@ class Request(dict):
self._cookies = None self._cookies = None
self.stream = None self.stream = None
def __repr__(self):
if self.method is None or not self._parsed_url:
return '<%s>' % self.__class__.__name__
return '<%s: %s %r>' % (self.__class__.__name__, self.method, self.path)
@property @property
def json(self): def json(self):
if self.parsed_json is None: if self.parsed_json is None: