HTTPのRangeに対応するCPANモジュール

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
# Amon2のコントローラーと思ってください
# 簡素化のため色々と省いています
sub contents {
    my ($class, $c, $args) = @_;
    my $id = $args->{id};
    my $row = $c->db->single('movies', {id => $id});
    my $path = path($row->content_path);
    return $c->res_404 unless $path->is_file;
    my $refs = Plack::App::File::Range->new->serve_path($c->req->env,
        $path->stringify);
    return $c->create_response(@$refs);
}
comments powered by Disqus
Built with Hugo
Theme Stack designed by Jimmy