Plack::Middleware::XFramework - Sample middleware to add X-Framework


Plack documentation Contained in the Plack distribution.

Index


Code Index:

NAME

Top

Plack::Middleware::XFramework - Sample middleware to add X-Framework

SYNOPSIS

Top

  enable "Plack::Middleware::XFramework", framework => "Catalyst";

DESCRIPTION

Top

This middleware adds X-Framework header to the HTTP response.

CONFIGURATION

Top

framework

Sets the string value of X-Framework header. If not set, the header is not set to the response.

SEE ALSO

Top

Plack::Middleware


Plack documentation Contained in the Plack distribution.

package Plack::Middleware::XFramework;
use strict;
use warnings;
use parent qw/Plack::Middleware/;

use Plack::Util;
use Plack::Util::Accessor qw( framework );

sub call {
    my $self = shift;

    my $res = $self->app->( @_ );
    $self->response_cb($res, sub {
        my $res = shift;
        if ($self->framework) {
            Plack::Util::header_set $res->[1], 'X-Framework' => $self->framework;
        }
    });
}

1;

__END__