Make content a positional argument
[fwx] / phial.py
index bce8979..f76a5dc 100644 (file)
--- a/phial.py
+++ b/phial.py
@@ -18,7 +18,7 @@ _Response = collections.namedtuple(
 )
 
 class Response(_Response):
-    def __new__(cls, **kwargs):
+    def __new__(cls, content, **kwargs):
         status = kwargs.pop('status', 200)
         assert isinstance(status, int)
 
@@ -28,8 +28,6 @@ class Response(_Response):
         extra_headers = kwargs.pop('extra_headers', ())
         assert isinstance(extra_headers, tuple)
 
-        content = kwargs.pop('content')
-
         assert len(kwargs) == 0
 
         return super().__new__(
@@ -46,6 +44,16 @@ class Response(_Response):
             ('Content-Type', self.content_type),
         )
 
+class TextResponse(Response):
+    def __new__(cls, content, **kwargs):
+        assert 'content_type' not in kwargs
+        return super().__new__(
+            cls,
+            content,
+            content_type='text/plain',
+            **kwargs,
+        )
+
 def _get_status(response):
     return {
         200: '200 OK',