Skip to content

Commit

Permalink
added example for serving a static file only if it exists
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Nov 29, 2014
1 parent 3aa3d01 commit cfbb272
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Changes
@@ -1,5 +1,5 @@

5.68 2014-11-28
5.68 2014-11-29

5.67 2014-11-27
- Improved overall performance by deserializing sessions only on demand.
Expand Down
6 changes: 6 additions & 0 deletions lib/Mojolicious/Plugin/DefaultHelpers.pm
Expand Up @@ -384,6 +384,12 @@ C<Range>, C<If-Modified-Since> and C<If-None-Match> headers.
$c->res->headers->content_type('text/plain');
$c->reply->asset($asset);
# Serve static file if it exists
if (my $asset = $c->app->static->file('/foo/index.html')) {
$c->res->headers->content_type('text/html');
$c->reply->static($asset);
}
=head2 reply->exception
$c = $c->reply->exception('Oops!');
Expand Down

0 comments on commit cfbb272

Please sign in to comment.