added category API

This commit is contained in:
Finn 2018-01-15 14:18:27 +00:00
parent 4e74c871a2
commit 4369a95054
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('/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');

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 Search by location as well
sub post_search {