### Stable endpoints
/$LISTNAME/m/$MESSAGE_ID.html -> HTML content (short quotes)
-/$LISTNAME/m/$MESSAGE_ID.txt -> raw original
+/$LISTNAME/m/$MESSAGE_ID.txt -> raw mbox
/$LISTNAME/m/$MESSAGE_ID -> 301 to .html version
/$LISTNAME/f/$MESSAGE_ID.html -> HTML content (full quotes)
/$LISTNAME/f/$MESSAGE_ID -> 301 to .html version
use strict;
use warnings;
use PublicInbox::MID qw/mid_compressed mid2path/;
+require Email::Simple;
sub thread_mbox {
my ($ctx, $srch, $sfx) = @_;
}
}
+sub emit1 {
+ my $simple = Email::Simple->new(pop);
+ sub {
+ my ($response) = @_;
+ # single message should be easily renderable in browsers
+ my $fh = $response->([200, ['Content-Type'=>'text/plain']]);
+ emit_msg($fh, $simple);
+ }
+}
+
sub emit_msg {
my ($fh, $simple) = @_; # Email::Simple object
$fh = PublicInbox::MboxGz->new($fh) if $sfx;
require PublicInbox::GitCatFile;
- require Email::Simple;
my $mid = mid_compressed($ctx->{mid});
my $git = PublicInbox::GitCatFile->new($ctx->{git_dir});
my %opts = (offset => 0);
}
}
-# /$LISTNAME/m/$MESSAGE_ID.txt -> raw original
+# /$LISTNAME/m/$MESSAGE_ID.txt -> raw mbox
sub get_mid_txt {
my ($ctx, $cgi) = @_;
- my $x = mid2blob($ctx);
- $x ? [ 200, [ 'Content-Type' => 'text/plain' ], [ $$x ] ] : r404();
+ my $x = mid2blob($ctx) or return r404();
+ require PublicInbox::Mbox;
+ PublicInbox::Mbox::emit1($x);
}
# /$LISTNAME/m/$MESSAGE_ID.html -> HTML content (short quotes)