Jakob Voß > Plack-Middleware-Headers-0.10 > Plack::Middleware::Headers

Download:
Plack-Middleware-Headers-0.10.tar.gz

Dependencies

Annotate this POD

Website

View/Report Bugs
Module Version: 0.10   Source   Latest Release: Plack-Middleware-Headers-0.11

NAME ^

Plack::Middleware::Headers - modify HTTP response headers

VERSION ^

version 0.10

SYNOPSIS ^

  use Plack::Builder;

  builder {
      enable 'Headers',
        set    => ['X-Plack-One' => '1'],
        append => ['X-Plack-Two' => '2'],
        unset  => ['X-Plack-Three'];
      enable 'Headers',
        code   => '404',
        set    => ['X-Robots-Tag' => 'noindex, noarchive, follow'];
      enable 'Headers',
        when   => ['Content-Type' => qr{^text/}],
        set    => ['Content-Type' => 'text/plain'];

      sub {['200', [], ['hello']]};
  };

DESCRIPTION ^

This Plack::Middleware simplifies creation (set or append), deletion (unset), and modification (set) of PSGI response headers. The modification can be enabled based on response code (code) or existing response headers(when). Use Plack::Middleware::Conditional to enable the middleware based in request headers.

CONFIGURATION ^

set

Overwrites existent header(s).

unset

Remove existing header(s).

append

Add header(s).

code

Optional HTTP response code that modification of response headers is limited to.

when

Optional check on the response headers that must be true to actually modify headers. Either one provides a list of headers for which one of them must match. Matching can be tested against:

    header => undef,    # missing header
    header => $scalar   # exact value
    header => /$regexp/ # regular expression

Alternatively one can check with a code reference that all response headers are passed to as list.

CONTRIBUTORS ^

This module is an extened fork of Plack::Middleware::Header, originally created by Masahiro Chiba. Additional contributions by Wallace Reis.

SEE ALSO ^

Plack::Middleware, Plack::Builder

AUTHOR ^

Jakob Voß

COPYRIGHT AND LICENSE ^

This software is copyright (c) 2013 by Jakob Voß.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.

syntax highlighting: