|
Revision 18451, 1.0 kB
(checked in by tokuhirom, 5 years ago)
|
|
make immutable
|
| Line | |
|---|
| 1 | package App::Mobirc::Plugin::Component::HTTPD; |
|---|
| 2 | use strict; |
|---|
| 3 | use MooseX::Plaggerize::Plugin; |
|---|
| 4 | |
|---|
| 5 | use App::Mobirc; |
|---|
| 6 | use App::Mobirc::Util; |
|---|
| 7 | use App::Mobirc::Web::Handler; |
|---|
| 8 | |
|---|
| 9 | use HTTP::Engine; |
|---|
| 10 | use App::Mobirc::Web::Middleware::Encoding; |
|---|
| 11 | use App::Mobirc::Web::Middleware::MobileAgent; |
|---|
| 12 | |
|---|
| 13 | has address => ( |
|---|
| 14 | is => 'ro', |
|---|
| 15 | isa => 'Str', |
|---|
| 16 | default => '0.0.0.0', |
|---|
| 17 | ); |
|---|
| 18 | |
|---|
| 19 | has port => ( |
|---|
| 20 | is => 'ro', |
|---|
| 21 | isa => 'Int', |
|---|
| 22 | default => 80, |
|---|
| 23 | ); |
|---|
| 24 | |
|---|
| 25 | hook run_component => sub { |
|---|
| 26 | my ( $self, $global_context ) = @_; |
|---|
| 27 | |
|---|
| 28 | HTTP::Engine->new( |
|---|
| 29 | interface => { |
|---|
| 30 | module => 'POE', |
|---|
| 31 | args => { |
|---|
| 32 | host => $self->address, |
|---|
| 33 | port => $self->port, |
|---|
| 34 | alias => 'mobirc_httpd', |
|---|
| 35 | }, |
|---|
| 36 | request_handler => App::Mobirc::Web::Middleware::Encoding->wrap( \&App::Mobirc::Web::Handler::handler ), |
|---|
| 37 | } |
|---|
| 38 | )->run; |
|---|
| 39 | |
|---|
| 40 | # default plugins |
|---|
| 41 | $global_context->load_plugin('StickyTime'); |
|---|
| 42 | }; |
|---|
| 43 | |
|---|
| 44 | no Moose; __PACKAGE__->meta->make_immutable; |
|---|
| 45 | 1; |
|---|