diff options
author | David Lawrence <dkl@mozilla.com> | 2014-08-26 21:45:40 +0200 |
---|---|---|
committer | David Lawrence <dkl@mozilla.com> | 2014-08-26 21:45:40 +0200 |
commit | b888aaa25fd0775e022e196ed8f56e766e766098 (patch) | |
tree | d7dbd977106816c113a3e3740c07dc0274743b5a /extensions | |
parent | bfc1cfe2b6f723b260d90363b7eccbb8e3297f89 (diff) | |
download | bugzilla-b888aaa25fd0775e022e196ed8f56e766e766098.tar.gz bugzilla-b888aaa25fd0775e022e196ed8f56e766e766098.tar.xz |
Bug 1057774: bzAPI landing page gives a 404
Diffstat (limited to 'extensions')
-rw-r--r-- | extensions/BzAPI/Extension.pm | 8 | ||||
-rw-r--r-- | extensions/BzAPI/lib/Constants.pm | 5 | ||||
-rw-r--r-- | extensions/BzAPI/lib/Resources/Bugzilla.pm | 20 |
3 files changed, 31 insertions, 2 deletions
diff --git a/extensions/BzAPI/Extension.pm b/extensions/BzAPI/Extension.pm index 0790e6596..cd08369b0 100644 --- a/extensions/BzAPI/Extension.pm +++ b/extensions/BzAPI/Extension.pm @@ -146,8 +146,12 @@ sub webservice_rest_response { $cache->{bzapi_rpc} ||= $rpc; return if !Bugzilla->request_cache->{bzapi} - || ref $$result ne 'HASH' - || exists $$result->{error}; + || ref $$result ne 'HASH'; + + if (exists $$result->{error}) { + $$result->{documentation} = BZAPI_DOC; + return; + } # Load the appropriate response handler based on path and type if (my $handler = _find_handler($rpc, 'response')) { diff --git a/extensions/BzAPI/lib/Constants.pm b/extensions/BzAPI/lib/Constants.pm index c36543daf..65ae00480 100644 --- a/extensions/BzAPI/lib/Constants.pm +++ b/extensions/BzAPI/lib/Constants.pm @@ -17,6 +17,8 @@ our @EXPORT = qw( ATTACHMENT_FIELD_MAP DEFAULT_BUG_FIELDS DEFAULT_ATTACHMENT_FIELDS + + BZAPI_DOC ); # These are fields that are normally exported as a single value such @@ -147,4 +149,7 @@ use constant ATTACHMENT_FIELD_MAP => { 'type' => 'content_type', }; +# A base link to the current BzAPI Documentation. +use constant BZAPI_DOC => 'https://wiki.mozilla.org/Bugzilla:BzAPI'; + 1; diff --git a/extensions/BzAPI/lib/Resources/Bugzilla.pm b/extensions/BzAPI/lib/Resources/Bugzilla.pm index 6c436e861..26aae0849 100644 --- a/extensions/BzAPI/lib/Resources/Bugzilla.pm +++ b/extensions/BzAPI/lib/Resources/Bugzilla.pm @@ -17,6 +17,9 @@ use Bugzilla::Keyword; use Bugzilla::Product; use Bugzilla::Status; use Bugzilla::Field; +use Bugzilla::Util qw(correct_urlbase); + +use Bugzilla::Extension::BzAPI::Constants; use Digest::MD5 qw(md5_base64); @@ -27,10 +30,18 @@ use Digest::MD5 qw(md5_base64); BEGIN { require Bugzilla::WebService::Bugzilla; *Bugzilla::WebService::Bugzilla::get_configuration = \&get_configuration; + *Bugzilla::WebService::Bugzilla::get_empty = \&get_empty; } sub rest_handlers { my $rest_handlers = [ + qr{^/$}, { + GET => { + resource => { + method => 'get_empty' + } + } + }, qr{^/configuration$}, { GET => { resource => { @@ -115,4 +126,13 @@ sub get_configuration { return $result; } +sub get_empty { + my ($self) = @_; + return { + urlbase => $self->type('string', correct_urlbase() . "bzapi/"), + documentation => $self->type('string', BZAPI_DOC), + version => $self->type('string', BUGZILLA_VERSION) + }; +} + 1; |