File: Metal.pm

package info (click to toggle)
libcatalyst-engine-psgi-perl 0.13%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 444 kB
  • sloc: perl: 5,307; sh: 48; makefile: 2
file content (50 lines) | stat: -rw-r--r-- 1,016 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package Catalyst::Controller::Metal;
use Moose;
extends 'Catalyst::Component';
with 'Catalyst::Component::ApplicationAttribute';

my %metals;

sub BUILD {
    my($self, $args) = @_;
    push @{$metals{$self->_application}}, $self;
}

sub metals_for {
    my($class, $application) = @_;
    @{$metals{$application} || []};
}

__PACKAGE__->meta->make_immutable;

1;

__END__

=head1 NAME

Catalyst::Controller::Metal - Raw PSGI handling in Catalyst controllers

=head1 SYNOPSIS

  package MyApp::Controller::Metalic;
  use parent 'Catalyst::Controller::Metal';

  sub call {
      my($self, $env) = @_;
      if ($env->{PATH_INFO} =~ m!^/hello!) {
          return [ 200, [ "Content-Type" => 'text/plain' ], [ "Hello World" ] ];
      } else {
          return [ 404, [], [] ];
      }
  }

Catalyst::Controller::Metal allows you to write a raw PSGI handler in
your Catalyst application, inspired by Rails Metal that allows you to
write raw Rack applications inside Ruby on Rails.

=head1 SEE ALSO

Rails Metal.

=cut