From 12dafd07b87e3412f48cfb3672c1804b3879464c Mon Sep 17 00:00:00 2001 From: huyuhan Date: Fri, 15 Sep 2017 18:34:56 +0800 Subject: [PATCH] add __repr__ for sanic request --- sanic/request.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sanic/request.py b/sanic/request.py index 27ff011e..4e8a2e07 100644 --- a/sanic/request.py +++ b/sanic/request.py @@ -68,6 +68,11 @@ class Request(dict): self._cookies = 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 def json(self): if self.parsed_json is None: