diff --git a/lib/Pear/LocalLoop.pm b/lib/Pear/LocalLoop.pm index 0146d63..32814cf 100644 --- a/lib/Pear/LocalLoop.pm +++ b/lib/Pear/LocalLoop.pm @@ -144,6 +144,7 @@ sub startup { }); $api->post('/upload')->to('api-upload#post_upload'); $api->post('/search')->to('api-upload#post_search'); + $api->post('/search/category')->to('api-upload#post_category'); $api->post('/user')->to('api-user#post_account'); $api->post('/user/account')->to('api-user#post_account_update'); $api->post('/user-history')->to('api-user#post_user_history'); diff --git a/lib/Pear/LocalLoop/Controller/Api/Upload.pm b/lib/Pear/LocalLoop/Controller/Api/Upload.pm index 3783d7f..26cc34d 100644 --- a/lib/Pear/LocalLoop/Controller/Api/Upload.pm +++ b/lib/Pear/LocalLoop/Controller/Api/Upload.pm @@ -209,6 +209,20 @@ sub post_upload { }); } +sub post_category { + my $c = shift; + my $self = $c; + + my $category_rs = $c->schema->resultset('Category'); + $category_rs->result_class('DBIx::Class::ResultClass::HashRefInflator'); + $categories => [ $category_rs->all ] ); + + return $self->render( json => { + success => Mojo::JSON->true, + categories => $categories, + }); +} + # TODO Limit search results, possibly paginate them? # TODO Search by location as well sub post_search {