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 serializer => "JSON";
|
||||||
set database => "db/booru.db";
|
set database => "db/booru.db";
|
||||||
|
|
||||||
my $DEFAULT_CONTENT_TYPE = "application/json";
|
use constant {
|
||||||
my @ROUTES = (
|
ROUTES => [
|
||||||
{ path => "/meta", verb => "GET" },
|
{ path => "/meta", verb => "GET" },
|
||||||
{ path => "/tags", verb => "GET" },
|
{ path => "/tags", verb => "GET" },
|
||||||
{ path => "/tags/new", verb => "POST" },
|
{ path => "/tags/new", verb => "POST" },
|
||||||
{ path => "/tag/:tag_id_or_name", verb => "GET" },
|
{ path => "/tag/:tag_id_or_name", verb => "GET" },
|
||||||
{ path => "/media/:media_id", verb => "GET" },
|
{ path => "/media/:media_id", verb => "GET" },
|
||||||
{ path => "/download/:media_id", verb => "GET" },
|
{ path => "/download/:media_id", verb => "GET" },
|
||||||
{ path => "/random", verb => "GET" },
|
{ path => "/random", verb => "GET" },
|
||||||
);
|
],
|
||||||
|
|
||||||
|
DEFAULT_CONTENT_TYPE => "application/json",
|
||||||
|
};
|
||||||
|
|
||||||
get "/meta" => sub {
|
get "/meta" => sub {
|
||||||
return \@ROUTES;
|
return ROUTES;
|
||||||
};
|
};
|
||||||
|
|
||||||
get "/tags" => sub {
|
get "/tags" => sub {
|
||||||
@ -96,7 +99,7 @@ get "/download/:media_id" => sub {
|
|||||||
|
|
||||||
send_file(
|
send_file(
|
||||||
\$media->content,
|
\$media->content,
|
||||||
content_type => $media->content_type // $DEFAULT_CONTENT_TYPE,
|
content_type => $media->content_type // DEFAULT_CONTENT_TYPE,
|
||||||
filename => $media->filename,
|
filename => $media->filename,
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user