Snippets

Brian Medley Possible to reply to a request immediately and then continue processing the request?

Created by Brian Medley
#!/usr/bin/env perl

use Mojolicious::Lite;

sub weird {
    my $app = shift;
    my $param = shift;

    return sub {
        my $loop = shift;

        $app->log->debug("Too weird to jumble: $param");
    }
};

get '/' => sub {
    my $c = shift;

    my $weird = weird($c->app, $c->param("name") // "Bender");

    Mojo::IOLoop->next_tick($weird);
    
    $c->render(template => 'index');
};

app->start;

__DATA__

@@ index.html.ep
Hi

Comments (0)

HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.