example of api call being handled by ajax call

This commit is contained in:
Oliver Gorwits
2019-03-17 08:57:40 +00:00
parent fc02f2c2dd
commit 33f94eac62
3 changed files with 36 additions and 6 deletions

View File

@@ -232,6 +232,14 @@ hook 'after' => sub {
}
};
# forward API calls to AJAX route handlers
any '/api/:type/:identifier/:method' => require_login sub {
vars->{'is_api'} = 1;
my $target =
sprintf '/ajax/content/%s/%s', params->{'type'}, params->{'method'};
forward $target, { tab => params->{'method'}, q => params->{'identifier'} };
};
any qr{.*} => sub {
var('notfound' => true);
status 'not_found';