| Catalyst-Plugin-Server-JSONRPC documentation | Contained in the Catalyst-Plugin-Server-JSONRPC distribution. |
Catalyst::Plugin::Server::JSONRPC::DispatchType::JSONRPCRegex - JSONRPCRegex DispatchType
See Catalyst.
Generates a nice debug-table containing the JSONRPCRegex methods.
Registers the JSONRPCPath actions into the dispatcher
Sergey Nosenko darknos@cpan.org
Catalyst::Plugin::Server::JSONRPC::DispatchType::JSONRPCRegex of
Michiel Ootjers michiel@cpan.org
Jos Boumans, kane@cpan.org
This program is free software, you can redistribute it and/or modify it under the same terms as Perl itself.
| Catalyst-Plugin-Server-JSONRPC documentation | Contained in the Catalyst-Plugin-Server-JSONRPC distribution. |
package Catalyst::Plugin::Server::JSONRPC::DispatchType::JSONRPCRegex; use strict; use base qw/Catalyst::DispatchType::Regex/; use Text::SimpleTable;
sub list { my ( $self, $c ) = @_; my $re = Text::SimpleTable->new( [ 36, 'JSONRPCRegex' ], [ 37, 'Private' ] ); for my $regex ( @{ $self->{_compiled} } ) { my $action = $regex->{action}; $re->row( $regex->{path}, "/$action" ); } $c->log->debug( "Loaded JSONRPCRegex actions:\n" . $re->draw ) if ( @{ $self->{_compiled} } ); }
sub register { my ( $self, $c, $action ) = @_; my $attrs = $action->attributes; my @register = map { @{ $_ || [] } } @{$attrs}{ 'JSONRPCRegex', 'JSONRPCRegexp' }; foreach my $r ( map { @{ $_ || [] } } @{$attrs}{ 'JSONRPCLocalRegex', 'JSONRPCLocalRegexp' } ) { unless ( $r =~ s/^\^// ) { $r = "(?:.*?)$r"; } push( @register, '^' . $action->namespace . '/' . $r ); } foreach my $r (@register) { $self->register_path( $c, $r, $action ); $self->register_regex( $c, $r, $action ); } return 1 if @register; return 0; }
1;