skeleton PSGI response test
[scpubgit/App-SCS.git] / lib / App / SCS / Plugin / Feeds.pm
CommitLineData
632f0e07 1package App::SCS::Plugin::Feeds;
2
3use Module::Runtime qw(use_module);
4use Moo;
5
6with 'App::SCS::Role::Plugin';
7
8has mount_at => (is => 'ro', default => sub { 'feed' });
9
10has generator => (
11 is => 'lazy',
12 handles => { _feed_http_response => 'feed_http_response' },
13);
14
15sub _build_generator {
16 my ($self) = @_;
17 use_module('App::SCS::Plugin::Feeds::Generator')->new(
18 pages => $self->pages,
19 mounted_at => $self->mount_at,
20 );
21}
22
23sub page_dispatchers {
24 my ($self) = @_;
25 my $base = $self->mount_at;
26 "/${base}/**/" => sub {
27 if (my $conf = $self->config->{$_[1]}) {
28 $self->_feed_http_response(200 => $conf => $_[-1]);
29 }
30 },
31}
32
33sub provides_pages {
34 my ($self) = @_;
35 my $base = $self->mount_at;
36 return map "/${base}/$_/", keys %{$self->config};
37}
38
391;