import phial
def handler(request):
- return phial.Response(
- content_type='text/plain',
+ return phial.TextResponse(
content='Hello, world\n',
)
)
class Response(_Response):
- def __new__(cls, **kwargs):
+ def __new__(cls, content, **kwargs):
status = kwargs.pop('status', 200)
assert isinstance(status, int)
extra_headers = kwargs.pop('extra_headers', ())
assert isinstance(extra_headers, tuple)
- content = kwargs.pop('content')
-
assert len(kwargs) == 0
return super().__new__(
('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',