package HTTP::Throwable::Role::Status::ServiceUnavailable 0.028;
our $AUTHORITY = 'cpan:STEVAN';

use Types::Standard qw(Str);

use Moo::Role;

with(
    'HTTP::Throwable',
    'HTTP::Throwable::Role::BoringText',
);

sub default_status_code { 503 }
sub default_reason      { 'Service Unavailable' }

has 'retry_after' => ( is => 'ro', isa => Str );

around 'build_headers' => sub {
    my $next    = shift;
    my $self    = shift;
    my $headers = $self->$next( @_ );
    if ( my $retry = $self->retry_after ) {
        push @$headers => ('Retry-After' => $retry);
    }
    $headers;
};

no Moo::Role; 1;

=pod

=encoding UTF-8

=head1 NAME

HTTP::Throwable::Role::Status::ServiceUnavailable - 503 Service Unavailable

=head1 VERSION

version 0.028

=head1 DESCRIPTION

The server is currently unable to handle the request due to
a temporary overloading or maintenance of the server. The
implication is that this is a temporary condition which will
be alleviated after some delay. If known, the length of the
delay MAY be indicated in a Retry-After header. If no
Retry-After is given, the client SHOULD handle the response as
it would for a 500 response.

  Note: The existence of the 503 status code does not imply that a
  server must use it when becoming overloaded. Some servers may wish
  to simply refuse the connection.

=head1 PERL VERSION

This library should run on perls released even a long time ago.  It should work
on any version of perl released in the last five years.

Although it may work on older versions of perl, no guarantee is made that the
minimum required version will not be increased.  The version may be increased
for any reason, and there is no promise that patches will be accepted to lower
the minimum required perl.

=head1 AUTHORS

=over 4

=item *

Stevan Little <stevan.little@iinteractive.com>

=item *

Ricardo Signes <cpan@semiotic.systems>

=back

=head1 COPYRIGHT AND LICENSE

This software is copyright (c) 2011 by Infinity Interactive, Inc.

This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.

=cut

__END__

# ABSTRACT: 503 Service Unavailable

#pod =head1 DESCRIPTION
#pod
#pod The server is currently unable to handle the request due to
#pod a temporary overloading or maintenance of the server. The
#pod implication is that this is a temporary condition which will
#pod be alleviated after some delay. If known, the length of the
#pod delay MAY be indicated in a Retry-After header. If no
#pod Retry-After is given, the client SHOULD handle the response as
#pod it would for a 500 response.
#pod
#pod   Note: The existence of the 503 status code does not imply that a
#pod   server must use it when becoming overloaded. Some servers may wish
#pod   to simply refuse the connection.
#pod
#pod
