From 63368ba06e18a3d91df0c40befc2231b03c5165b Mon Sep 17 00:00:00 2001 From: Lucas Date: Sat, 18 Feb 2023 16:10:45 +0000 Subject: [PATCH] api: use 'constant' for constants --- lib/PoorBooru/API/V0.pm | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/lib/PoorBooru/API/V0.pm b/lib/PoorBooru/API/V0.pm index 2d048ff..3b0e9e6 100644 --- a/lib/PoorBooru/API/V0.pm +++ b/lib/PoorBooru/API/V0.pm @@ -7,19 +7,22 @@ our $VERSION = v0; set serializer => "JSON"; set database => "db/booru.db"; -my $DEFAULT_CONTENT_TYPE = "application/json"; -my @ROUTES = ( - { path => "/meta", verb => "GET" }, - { path => "/tags", verb => "GET" }, - { path => "/tags/new", verb => "POST" }, - { path => "/tag/:tag_id_or_name", verb => "GET" }, - { path => "/media/:media_id", verb => "GET" }, - { path => "/download/:media_id", verb => "GET" }, - { path => "/random", verb => "GET" }, -); +use constant { + ROUTES => [ + { path => "/meta", verb => "GET" }, + { path => "/tags", verb => "GET" }, + { path => "/tags/new", verb => "POST" }, + { path => "/tag/:tag_id_or_name", verb => "GET" }, + { path => "/media/:media_id", verb => "GET" }, + { path => "/download/:media_id", verb => "GET" }, + { path => "/random", verb => "GET" }, + ], + + DEFAULT_CONTENT_TYPE => "application/json", +}; get "/meta" => sub { - return \@ROUTES; + return ROUTES; }; get "/tags" => sub { @@ -96,7 +99,7 @@ get "/download/:media_id" => sub { send_file( \$media->content, - content_type => $media->content_type // $DEFAULT_CONTENT_TYPE, + content_type => $media->content_type // DEFAULT_CONTENT_TYPE, filename => $media->filename, ); };