my $api = $r->under('/api/v1');
$api->post('/login')->to('API::Login#login');
+ $api->get('/sidebar/item')->to('API::SidebarItem#get', seclev => 1);
+
$api->get('/comment')->to('API::Comment#get');
$api->post('/comment')->to('API::Comment#post', captcha_check => 1, csrf_check_id => 'comment');
--- /dev/null
+package Newslash::Web::Controller::API::SidebarItem;
+use Mojo::Base 'Newslash::Web::Controller';
+
+sub get {
+ my $c = shift;
+ my $boxes = $c->app->model('boxes');
+ my $items = $boxes->select;
+
+ if (!defined $items) {
+ $c->rendered(500);
+ $c->render(json => {error => 1, message => $boxes->last_error});
+ return;
+ }
+
+ $c->render(json => {items => $items});
+ return;
+}
+
+
+1;
user_id: params.user_id,
message: "",
urls: {
- get: '/api/v1/sidebars',
+ get: '/api/v1/sidebar/item',
save: '/api/v1/user',
user: '/api/v1/user?type=sidebar',
},
->json_has('/item/query_params')
->json_has('/item/template');
+ $t->get_ok("/api/v1/sidebar/item")
+ ->status_is(200)
+ ->json_has('/items')
+ ->json_has('/items/0/id')
+ ->json_has('/items/0/name')
+ ->json_has('/items/0/comment')
+ ->json_has('/items/0/model')
+ ->json_has('/items/0/query_params')
+ ->json_has('/items/0/template');
+
# export
unlink("/var/tmp/boxes.json");
$t->get_ok("/api/v1/admin/repository/export?target=boxes")