added category API

This commit is contained in:
Finn 2018-01-15 14:18:27 +00:00
parent b12cd3fcfc
commit 5a88c283d5
2 changed files with 15 additions and 0 deletions

View file

@ -144,6 +144,7 @@ sub startup {
}); });
$api->post('/upload')->to('api-upload#post_upload'); $api->post('/upload')->to('api-upload#post_upload');
$api->post('/search')->to('api-upload#post_search'); $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')->to('api-user#post_account');
$api->post('/user/account')->to('api-user#post_account_update'); $api->post('/user/account')->to('api-user#post_account_update');
$api->post('/user-history')->to('api-user#post_user_history'); $api->post('/user-history')->to('api-user#post_user_history');

View file

@ -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 Limit search results, possibly paginate them?
# TODO Search by location as well # TODO Search by location as well
sub post_search { sub post_search {