Skip to content

Commit

Permalink
Support directory index files
Browse files Browse the repository at this point in the history
If a component is not found for a path, assume path is a directory and
search for directory index files.

For now we hardcode the files to 'index.html' and 'index.htm' but it could
be a configuration.

Also the search order is wrong with multiple components. A proper solution
would be to move this to Interp.pm. Patches welcome :).

Signed-off-by: Pedro Melo <melo@simplicidade.org>
  • Loading branch information
melo committed Sep 19, 2009
1 parent 0f80f6c commit 2360faa
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/HTML/Mason/Request.pm
Expand Up @@ -248,6 +248,16 @@ sub _initialize {

last search unless $self->use_dhandlers;

# If path was not found, check for index.html-style files.
unless ($request_comp) {
my $index_path = $path;
$index_path .= '/' unless substr($index_path, -1) eq '/';
foreach my $index_file ('index.html', 'index.htm') {
$request_comp = $self->interp->load("$index_path$index_file");
last if $request_comp;
}
}

# If path was not found, check for dhandler.
unless ($request_comp) {
if ( $request_comp = $self->interp->find_comp_upwards($path, $self->dhandler_name) ) {
Expand Down

0 comments on commit 2360faa

Please sign in to comment.