summaryrefslogtreecommitdiffstats
path: root/Bugzilla
diff options
context:
space:
mode:
Diffstat (limited to 'Bugzilla')
-rw-r--r--Bugzilla/Quantum.pm2
-rw-r--r--Bugzilla/Quantum/CGI.pm37
2 files changed, 21 insertions, 18 deletions
diff --git a/Bugzilla/Quantum.pm b/Bugzilla/Quantum.pm
index dfa22d824..299b4bf42 100644
--- a/Bugzilla/Quantum.pm
+++ b/Bugzilla/Quantum.pm
@@ -45,6 +45,8 @@ sub startup {
my $r = $self->routes;
Bugzilla::Quantum::CGI->load_all($r);
+ Bugzilla::Quantum::CGI->load_one('bzapi_cgi', 'extensions/BzAPI/bin/rest.cgi');
+ $r->any('/bzapi/*PATH_INFO')->to('CGI#bzapi_cgi');
$r->any('/')->to('CGI#index_cgi');
$r->any('/rest')->to('CGI#rest_cgi');
diff --git a/Bugzilla/Quantum/CGI.pm b/Bugzilla/Quantum/CGI.pm
index 9874280bc..353d8651e 100644
--- a/Bugzilla/Quantum/CGI.pm
+++ b/Bugzilla/Quantum/CGI.pm
@@ -22,30 +22,20 @@ use Sys::Hostname;
use English qw(-no_match_vars);
our $C;
+my %SEEN;
sub load_all {
my ($class, $r) = @_;
- my $stash = Package::Stash->new(__PACKAGE__);
- foreach my $script (glob '*.cgi') {
- my ($name, $method) = $class->_load_cgi($script);
- $stash->add_symbol("&$name" => $method);
- $r->any("/$script")->to("CGI#$name");
+ foreach my $file (glob '*.cgi') {
+ my $name = _file_to_method($file);
+ $class->load_one($name, $file);
+ $r->any("/$file")->to("CGI#$name");
}
}
-sub _file_to_method {
- my ($name) = @_;
- $name =~ s/\./_/s;
- $name =~ s/\W+/_/gs;
- return $name;
-}
-
-my %SEEN;
-
-sub _load_cgi {
- my ($class, $file) = @_;
- my $name = _file_to_method($file);
+sub load_one {
+ my ($class, $name, $file) = @_;
my $package = __PACKAGE__ . "::$name",
my $inner_name = "_$name";
my $content = read_text( catfile( bz_locations->{cgi_path}, $file ) );
@@ -84,7 +74,10 @@ sub _load_cgi {
CGI::initialize_globals();
};
};
- return ($name, subname($name, $wrapper));
+
+ no strict 'refs'; ## no critic (strict)
+ *{$name} = subname($name, $wrapper);
+ return 1;
}
sub _ENV {
@@ -148,4 +141,12 @@ sub _STDIN {
return Mojo::Asset::File->new->add_chunk( $stdin->slurp );
}
+sub _file_to_method {
+ my ($name) = @_;
+ $name =~ s/\./_/s;
+ $name =~ s/\W+/_/gs;
+ return $name;
+}
+
+
1;