| 1 | ##---------------------------------------------------------------------------- | ||
| 2 | ## REST API Framework - ~/lib/Net/API/REST/Status.pm | ||
| 3 | ## Version v1.0.0 | ||
| 4 | ## Copyright(c) 2022 DEGUEST Pte. Ltd. | ||
| 5 | ## Author: Jacques Deguest <jack@deguest.jp> | ||
| 6 | ## Created 2019/12/15 | ||
| 7 | ## Modified 2023/06/10 | ||
| 8 | ## All rights reserved | ||
| 9 | ## | ||
| 10 | ## This program is free software; you can redistribute it and/or modify it | ||
| 11 | ## under the same terms as Perl itself. | ||
| 12 | ##---------------------------------------------------------------------------- | ||
| 13 | package Net::API::REST::Status; | ||
| 14 | BEGIN | ||
| 15 | { | ||
| 16 | use strict; | ||
| 17 | use warnings; | ||
| 18 | use common::sense; | ||
| 19 | use parent qw( Apache2::API::Status ); | ||
| 20 | use vars qw( $VERSION ); | ||
| 21 | our $VERSION = 'v1.0.0'; | ||
| 22 | }; | ||
| 23 | |||
| 24 | use strict; | ||
| 25 | use warnings; | ||
| 26 | |||
| 27 | 1; | ||
| 28 | # NOTE: POD | ||
| 29 | __END__ | ||
| 30 | |||
| 31 | =encoding utf8 | ||
| 32 | |||
| 33 | =head1 NAME | ||
| 34 | |||
| 35 | Net::API::REST::Status - Apache2 Status Codes | ||
| 36 | |||
| 37 | =head1 SYNOPSIS | ||
| 38 | |||
| 39 | say $Net::API::REST::Status::CODES->{429}; | ||
| 40 | # returns Apache constant Apache2::Const::HTTP_TOO_MANY_REQUESTS | ||
| 41 | |||
| 42 | say $Net::API::REST::Status::HTTP_CODES->{fr_FR}->{429} # Trop de requête | ||
| 43 | # In Japanese: リクエスト過大で拒否した | ||
| 44 | say $Net::API::REST::Status::HTTP_CODES->{ja_JP}->{429} | ||
| 45 | |||
| 46 | But maybe more simply: | ||
| 47 | |||
| 48 | my $status = Net::API::REST::Status->new; | ||
| 49 | say $status->status_message( 429 => 'ja_JP' ); | ||
| 50 | # Or without the language code parameter, it will default to en_GB | ||
| 51 | say $status->status_message( 429 ); | ||
| 52 | |||
| 53 | # Is success | ||
| 54 | say $status->is_info( 102 ); # true | ||
| 55 | say $status->is_success( 200 ); # true | ||
| 56 | say $status->is_redirect( 302 ); # true | ||
| 57 | say $status->is_error( 404 ); # true | ||
| 58 | say $status->is_client_error( 403 ); # true | ||
| 59 | say $status->is_server_error( 501 ); # true | ||
| 60 | |||
| 61 | =head1 VERSION | ||
| 62 | |||
| 63 | v1.0.0 | ||
| 64 | |||
| 65 | =head1 DESCRIPTION | ||
| 66 | |||
| 67 | As of version C<1.0.0>, this module inherits all of its methods from L<Apache2::API::Status>. Please check its documentation directly. | ||
| 68 | |||
| 69 | =head2 SEE ALSO | ||
| 70 | |||
| 71 | Apache distribution and file C<httpd-2.x.x/include/httpd.h> | ||
| 72 | |||
| 73 | L<IANA HTTP codes list|http://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml> | ||
| 74 | |||
| 75 | =head1 COPYRIGHT & LICENSE | ||
| 76 | |||
| 77 | Copyright (c) 2019-2023 DEGUEST Pte. Ltd. | ||
| 78 | |||
| 79 | You can use, copy, modify and redistribute this package and associated | ||
| 80 | files under the same terms as Perl itself. | ||
| 81 | |||
| 82 | =cut |