#!perl use strict; use warnings; use Web::Machine; =pod This demostrates how you can easily handle situations like the site being down in a reasonably elegant way. touch site_down rm site_down =cut { package YAPC::NA::2012::Example110::Resource; use strict; use warnings; use parent 'Web::Machine::Resource'; sub content_types_provided { [ { 'text/html' => 'to_html' }, ] } sub to_html { '

Hello World

' } sub service_available { my $self = shift; return 1 unless -e './site_down'; $self->response->body(['

Service Unavailable

Please come back later.']); 0; } } Web::Machine->new( resource => 'YAPC::NA::2012::Example110::Resource' )->to_app;