From bab1140053117a729dab467af936f5c181ecddff Mon Sep 17 00:00:00 2001 From: Lucas Date: Sat, 18 Feb 2023 15:33:28 +0000 Subject: [PATCH] api: reorder routes --- lib/PoorBooru/API/V0.pm | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) 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;