This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use Mojo::Base -strict; | |
use utf8; | |
use Test::More tests => 4; | |
use Mojolicious::Lite; | |
use Test::Mojo; | |
# Tiny echo web service |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use Mojolicious::Lite; | |
use EV; | |
use AnyEvent; | |
use AnyEvent::Util; | |
get '/' => sub { | |
my $self = shift; | |
# Run Perl oneliner in separate process and capture STDOUT | |
fork_call { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package Mojolicious::Plugin::Coro; | |
use Mojo::Base 'Mojolicious::Plugin'; | |
use Coro; | |
use Mojo::IOLoop; | |
# Wrap application in coroutine and reschedule main coroutine in event loop | |
sub register { | |
my ($self, $app) = @_; | |
my $subscribers = $app->plugins->subscribers('around_dispatch'); |