Skip to content

Instantly share code, notes, and snippets.

@anazawa
Created August 14, 2012 05:56
Show Gist options
  • Select an option

  • Save anazawa/3346759 to your computer and use it in GitHub Desktop.

Select an option

Save anazawa/3346759 to your computer and use it in GitHub Desktop.
as_arrayref
# as_arrayref
package as_arrayref;
use strict;
use warnings;
use Blosxom::Header;
sub start { !$blosxom::static_entries }
sub last {
my $header = Blosxom::Header->instance:
return [
$header->status,
[ $header->flatten ],
[ $blosxom::output ],
];
}
package blosxom;
sub as_arrayref { as_arrayref->last }
1;
# blosxom.psgi
my $app = sub {
my $env = shift;
local %ENV = ( %ENV, %$env );
do 'blosxom.cgi';
blosxom->as_arrayref;
};
# PURPOSE
CGI::Parse::PSGI を使わずに PSGI 互換の coderef を返す。
# HOW
coderef が返す arrayref を as_arrayref プラグインが生成する。
# TODO
- print STDOUT
- CGI::initialize_globals
- do 文だと何度も実行できない? (->Shotgun?)
- Blosxom::Header は Expires ヘッダと Set-Cookie ヘッダを展開しない
- $header->flatten は Status ヘッダを含む
# DISCUSSION
Blosxom::Header を使わずに、
my @headers = split "$CGI::CRLF", CGI::header( $blosxom::header );
としても同じこと。
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment