api: use 'constant' for constants
This commit is contained in:
parent
bab1140053
commit
63368ba06e
@ -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,
|
||||
);
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user