Skip to content

ap/Plack-App-Hash

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NAME

Plack::App::Hash - Serve up the contents of a hash as a website

SYNOPSIS

use Plack::App::Hash;
my $app = Plack::App::Hash->new(
    content      => { '' => 'Hello World!' },
    default_type => 'text/plain',
)->to_app;

DESCRIPTION

This PSGI application responds to HTTP requests by looking up the request path in a hash and returning the value of that key (if found) as the response body.

This is useful for cases like inlining the content of a boilerplate static site into a single-page-application-in-a-module, or serving up a tied DBM hash that other programs can update while the web app itself contains very little logic – in short, for one-off hacks and scaling down.

CONFIGURATION

content

The content of your site. Each key-value pair will be one resource in your URI space. The key is its URI path without leading slash, the value is the content of the resource. Values must not be references.

headers (optional)

The headers of your resources. As in content, each key is a URI path without leading slash. The value of a key may be either an array reference or a string containing a JSON encoding of an array. In either case it is taken to mean the PSGI header array for the resource.

auto_type (optional)

If true, a Content-Type header value will be computed automatically for any responses which do not already have one by way of the headers hash.

default_type (optional)

The Content-Type value to use for any responses which would not otherwise have one, whether by matching headers or by auto_type fallback.