summaryrefslogtreecommitdiff
path: root/t/perl/test_harakiri.psgi
blob: 35a40dbfb40603cb99c36bb255581d22b9a9d4c2 (plain)
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
use strict;
use warnings;

{
    package psgix::harakiri::tester;
    sub DESTROY { print STDERR "$$: Calling DESTROY\n" }
}

uwsgi::atexit(
    sub {
        print STDERR "$$: Calling the atexit hook\n";
    }
);

sub {
    my $env = shift;

    die "PANIC: We should support psgix.harakiri here" unless $env->{'psgix.harakiri'};

    $env->{'psgix.harakiri.tester'} = bless {} => 'psgix::harakiri::tester';
    my $harakiri = $env->{QUERY_STRING};
    $env->{'psgix.harakiri.commit'} = $harakiri ? 1 : 0;

    return [200, [], [ $harakiri ? "We are about to destroy ourselves\n" : "We will live for another request\n" ]];
}