From e158d56a54d3c6d4890aa6ac4caa28a834279af0 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Thu, 30 Jun 2016 09:13:21 +0000 Subject: www_stream: add response wrapper sub This encapsulates an entire PSGI response array, hopefully making it easier to generate responses and avoid typos when setting the Content-Type. --- lib/PublicInbox/WwwStream.pm | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'lib/PublicInbox/WwwStream.pm') diff --git a/lib/PublicInbox/WwwStream.pm b/lib/PublicInbox/WwwStream.pm index d2bf318b..6de1b310 100644 --- a/lib/PublicInbox/WwwStream.pm +++ b/lib/PublicInbox/WwwStream.pm @@ -14,6 +14,12 @@ sub new { bless { nr => 0, cb => $cb, ctx => $ctx }, $class; } +sub response { + my ($class, $ctx, $code, $cb) = @_; + [ $code, [ 'Content-Type', 'text/html; charset=UTF-8' ], + $class->new($ctx, $cb) ] +} + sub _html_top ($) { my ($self) = @_; my $ctx = $self->{ctx}; -- cgit v1.2.3-24-ge0c7