From b06a5f44ac35f92a28498c90292eef1735df6f7d Mon Sep 17 00:00:00 2001 From: Dave Lawrence Date: Tue, 25 Feb 2014 21:43:57 +0000 Subject: Bug 972881 - Add hooks to Bugzilla/WebService/Server/REST.pm to allow for extensions to extend and alter REST data r=glob,a=justdave --- Bugzilla/WebService/Server/REST.pm | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'Bugzilla/WebService/Server') diff --git a/Bugzilla/WebService/Server/REST.pm b/Bugzilla/WebService/Server/REST.pm index f1e59873c..f4bc47c91 100644 --- a/Bugzilla/WebService/Server/REST.pm +++ b/Bugzilla/WebService/Server/REST.pm @@ -15,9 +15,10 @@ use parent qw(Bugzilla::WebService::Server::JSONRPC); use Bugzilla; use Bugzilla::Constants; use Bugzilla::Error; +use Bugzilla::Hook; +use Bugzilla::Util qw(correct_urlbase html_quote); use Bugzilla::WebService::Constants; use Bugzilla::WebService::Util qw(taint_data fix_credentials); -use Bugzilla::Util qw(correct_urlbase html_quote); # Load resource modules use Bugzilla::WebService::Server::REST::Resources::Bug; @@ -124,6 +125,9 @@ sub response { $result = $json_data->{result}; } + Bugzilla::Hook::process('webservice_rest_response', + { rpc => $self, result => \$result, response => $response }); + # Access Control $response->header("Access-Control-Allow-Origin", "*"); $response->header("Access-Control-Allow-Headers", "origin, content-type, accept"); @@ -226,8 +230,6 @@ sub _argument_type_check { taint_data($params); - Bugzilla->input_params($params); - # Now, convert dateTime fields on input. my $method = $self->bz_method_name; my $pkg = $self->{dispatch_path}->{$self->path_info}; @@ -262,6 +264,10 @@ sub _argument_type_check { eval "package $new_class;$isa_string;"; bless $self, $new_class; + # Allow extensions to modify the params post login + Bugzilla::Hook::process('webservice_rest_request', + { rpc => $self, params => $params }); + if ($params_is_array) { $params = [$params]; } @@ -377,6 +383,9 @@ sub _find_resource { $resources->{$module} = $module->rest_resources; } + Bugzilla::Hook::process('webservice_rest_resources', + { rpc => $self, resources => $resources }); + # Use the resources hash from each module loaded earlier to determine # which handler to use based on a regex match of the CGI path. # Also any matches found in the regex will be passed in later to the -- cgit v1.2.3-24-g4f1b