diff --git a/lib/PoorBooru/API/V0.pm b/lib/PoorBooru/API/V0.pm index 1977cb9..2d048ff 100644 --- a/lib/PoorBooru/API/V0.pm +++ b/lib/PoorBooru/API/V0.pm @@ -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;