Skip to content

Commit

Permalink
a few new event examples
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Oct 20, 2011
1 parent 6ceca27 commit e73e1de
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 3 deletions.
3 changes: 3 additions & 0 deletions Changes
@@ -1,5 +1,8 @@
This file documents the revision history for Perl extension Mojolicious.

2.03 2011-10-20 00:00:00
- Improved documentation.

2.02 2011-10-20 00:00:00
- Merged request and upgrade events in Mojo::Transaction::HTTP.
- Improved Mojolicious::Controller attribute default values.
Expand Down
2 changes: 1 addition & 1 deletion lib/Mojo/Content.pm
Expand Up @@ -463,7 +463,7 @@ storage in asset objects.
$content->on(read => sub {
my ($content, $chunk) = @_;
say "STREAMING: $chunk";
say "Streaming: $chunk";
});
=head1 ATTRIBUTES
Expand Down
8 changes: 8 additions & 0 deletions lib/Mojo/Message.pm
Expand Up @@ -582,6 +582,14 @@ Emitted after message building or parsing is finished.
Emitted when message building or parsing makes progress.
$message->on(progress => sub {
my $message = shift;
my $len = $message->headers->content_length;
my $progress = $message->content->progress;
say 'Progress: ',
$progress == $len ? 100 : int($progress / ($len / 100)), '%';
});
=head1 ATTRIBUTES
L<Mojo::Message> implements the following attributes.
Expand Down
5 changes: 5 additions & 0 deletions lib/Mojo/Transaction/HTTP.pm
Expand Up @@ -347,6 +347,11 @@ Emitted when a request is ready and needs to be handled, an optional
L<Mojo::Transaction::WebSocket> object will be passed for WebSocket handshake
requests.
$tx->on(request => sub {
my $tx = shift;
$tx->res->headers->header('X-Bender', 'Bite my shiny metal ass!');
});
=head1 ATTRIBUTES
L<Mojo::Transaction::HTTP> inherits all attributes from L<Mojo::Transaction>
Expand Down
2 changes: 1 addition & 1 deletion lib/Mojolicious.pm
Expand Up @@ -35,7 +35,7 @@ has static => sub { Mojolicious::Static->new };
has types => sub { Mojolicious::Types->new };

our $CODENAME = 'Leaf Fluttering In Wind';
our $VERSION = '2.02';
our $VERSION = '2.03';

# "These old doomsday devices are dangerously unstable.
# I'll rest easier not knowing where they are."
Expand Down
2 changes: 1 addition & 1 deletion t/pod_coverage.t
Expand Up @@ -11,7 +11,7 @@ plan skip_all => 'set TEST_POD to enable this test (developer only!)'
# DEPRECATED in Smiling Face With Sunglasses!
my @sunglasses = (
qw/add_after add_before append del inner_xml on_finish on_progress on_read/,
qw/on_request on_resume on_start on_upgrade render_inner replace_inner/,
qw/on_request on_resume on_start render_inner replace_inner/,
);

# "Marge, I'm going to miss you so much. And it's not just the sex.
Expand Down

0 comments on commit e73e1de

Please sign in to comment.