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/Extension.pm | |
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/Extension.pm')
-rw-r--r-- | extensions/Example/Extension.pm | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/extensions/Example/Extension.pm b/extensions/Example/Extension.pm index a866e85e6..1649957fd 100644 --- a/extensions/Example/Extension.pm +++ b/extensions/Example/Extension.pm @@ -1058,29 +1058,34 @@ sub webservice_rest_resources { my $resources = $args->{'resources'}; # Add a new resource that allows for /rest/example/hello # to call Example.hello - $resources->{'Bugzilla::Extension::Example::WebService'} = [ - qr{^/example/hello$}, { - GET => { - method => 'hello', - } - } - ]; + #$resources->{'Bugzilla::Extension::Example::WebService'} = [ + # qr{^/example/hello$}, { + # GET => { + # method => 'hello', + # } + # } + #]; } -sub webservice_rest_response { +sub webservice_rest_result { my ($self, $args) = @_; - my $rpc = $args->{'rpc'}; - my $result = $args->{'result'}; - my $response = $args->{'response'}; + my $result = $args->{'result'}; # Convert a list of bug hashes to a single bug hash if only one is # being returned. if (ref $$result eq 'HASH' && exists $$result->{'bugs'} + && ref $$result->{'bugs'} eq 'ARRAY' && scalar @{ $$result->{'bugs'} } == 1) { $$result = $$result->{'bugs'}->[0]; } } +sub webservice_rest_response { + my ($self, $args) = @_; + my $response = $args->{'response'}; + $response->header('X-Example-Header', 'This is an example header'); +} + # This must be the last line of your extension. __PACKAGE__->NAME; |