Moved all api endpoints to /api/* and added root controller

This commit is contained in:
Tom Bloor 2017-04-06 22:19:36 +01:00
parent 8bda8dba73
commit dbc2c59461
3 changed files with 24 additions and 13 deletions

View file

@ -36,21 +36,22 @@ sub startup {
my $r = $self->routes; my $r = $self->routes;
$r = $r->any('/api') if $self->app->mode ne 'testing'; $r->any('/')->to('root#index');
my $api = $r->any('/api');
$r->post("/register")->to('register#post_register'); $api->post("/register")->to('register#post_register');
$r->post("/upload")->to('upload#post_upload'); $api->post("/upload")->to('upload#post_upload');
$r->post("/search")->to('upload#post_search'); $api->post("/search")->to('upload#post_search');
$r->post("/admin-approve")->to('admin#post_admin_approve'); $api->post("/admin-approve")->to('admin#post_admin_approve');
$r->post("/admin-merge")->to('admin#post_admin_merge'); $api->post("/admin-merge")->to('admin#post_admin_merge');
$r->get("/login")->to('auth#get_login'); $api->get("/login")->to('auth#get_login');
$r->post("/login")->to('auth#post_login'); $api->post("/login")->to('auth#post_login');
$r->post("/logout")->to('auth#post_logout'); $api->post("/logout")->to('auth#post_logout');
$r->post("/edit")->to('api#post_edit'); $api->post("/edit")->to('api#post_edit');
$r->post("/fetchuser")->to('api#post_fetchuser'); $api->post("/fetchuser")->to('api#post_fetchuser');
$r->post("/user-history")->to('user#post_user_history'); $api->post("/user-history")->to('user#post_user_history');
$r->any( '/' => sub { $api->any( '/' => sub {
my $self = shift; my $self = shift;
return $self->render(json => { success => Mojo::JSON->true }); return $self->render(json => { success => Mojo::JSON->true });
}); });

View file

@ -0,0 +1,9 @@
package Pear::LocalLoop::Controller::Root;
use Mojo::Base 'Mojolicious::Controller';
sub index {
my $c = shift;
}
1;

View file

@ -0,0 +1 @@
Hello!