api: reorder routes
This commit is contained in:
parent
46cb5c19ec
commit
bab1140053
@ -13,9 +13,9 @@ my @ROUTES = (
|
||||
{ path => "/tags", verb => "GET" },
|
||||
{ path => "/tags/new", verb => "POST" },
|
||||
{ path => "/tag/:tag_id_or_name", verb => "GET" },
|
||||
{ path => "/random", verb => "GET" },
|
||||
{ path => "/media/:media_id", verb => "GET" },
|
||||
{ path => "/download/:media_id", verb => "GET" },
|
||||
{ path => "/random", verb => "GET" },
|
||||
);
|
||||
|
||||
get "/meta" => sub {
|
||||
@ -74,15 +74,6 @@ get "/tag/:tag_id_or_name" => sub {
|
||||
};
|
||||
};
|
||||
|
||||
get "/random" => sub {
|
||||
my $media = schema("default")->resultset("Media")
|
||||
->search({}, { order_by => \"random()", limit => 1 })->single;
|
||||
|
||||
send_error("Media not found", 404) if !defined($media);
|
||||
|
||||
forward "/media/" . $media->media_id;
|
||||
};
|
||||
|
||||
get "/media/:media_id" => sub {
|
||||
my $media = schema("default")->resultset("Media")
|
||||
->single({ media_id => route_parameters->get("media_id") });
|
||||
@ -110,4 +101,13 @@ get "/download/:media_id" => sub {
|
||||
);
|
||||
};
|
||||
|
||||
get "/random" => sub {
|
||||
my $media = schema("default")->resultset("Media")
|
||||
->search({}, { order_by => \"random()", limit => 1 })->single;
|
||||
|
||||
send_error("Media not found", 404) if !defined($media);
|
||||
|
||||
forward "/media/" . $media->media_id;
|
||||
};
|
||||
|
||||
true;
|
||||
|
Loading…
Reference in New Issue
Block a user