diff options
author | David Lawrence <dkl@mozilla.com> | 2015-04-08 19:48:36 +0200 |
---|---|---|
committer | David Lawrence <dkl@mozilla.com> | 2015-04-08 19:48:36 +0200 |
commit | dbfd6207290d1eee53fddec4c7c3b4aac0b2d47a (patch) | |
tree | aa190d8cc9e2b313dd7e85bf763c1bfe5502b75d /extensions/Example/API/1_0/Resource | |
parent | e6d2fb75aa3c183323c534a214f3dd9be5638676 (diff) | |
download | bugzilla-dbfd6207290d1eee53fddec4c7c3b4aac0b2d47a.tar.gz bugzilla-dbfd6207290d1eee53fddec4c7c3b4aac0b2d47a.tar.xz |
Bug 1051056: The REST API needs to be versioned so that new changes can be made that do not break compatibility
r=dylan,a=glob
Diffstat (limited to 'extensions/Example/API/1_0/Resource')
-rw-r--r-- | extensions/Example/API/1_0/Resource/Example.pm | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/extensions/Example/API/1_0/Resource/Example.pm b/extensions/Example/API/1_0/Resource/Example.pm new file mode 100644 index 000000000..c4c5f9a32 --- /dev/null +++ b/extensions/Example/API/1_0/Resource/Example.pm @@ -0,0 +1,59 @@ +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +# This Source Code Form is "Incompatible With Secondary Licenses", as +# defined by the Mozilla Public License, v. 2.0. + +package Bugzilla::API::1_0::Resource::Example; + +use 5.10.1; +use strict; +use warnings; +use parent qw(Bugzilla::API::1_0::Resource); +use Bugzilla::Error; + +############# +# Constants # +############# + +use constant READ_ONLY => qw( + hello + throw_an_error +); + +use constant PUBLIC_METHODS => qw( + hello + throw_an_error +); + +sub REST_RESOURCES { + my $rest_resources = [ + qr{^/hello$}, { + GET => { + method => 'hello' + } + }, + qr{^/throw_an_error$}, { + GET => { + method => 'throw_an_error' + } + } + ]; + return $rest_resources; +} + +########### +# Methods # +########### + +# This can be called as Example.hello() from the WebService. +sub hello { + return { + message => 'Hello!' + }; +} + +sub throw_an_error { ThrowUserError('example_my_error') } + +1; |