view release on metacpan or search on metacpan
lib/Cassandra/Types.pm view on Meta::CPAN
package Cassandra::TokenRange;
BEGIN {
$Cassandra::TokenRange::VERSION = '0.4.0';
}
use base qw(Class::Accessor);
Cassandra::TokenRange->mk_accessors( qw( start_token end_token endpoints ) );
sub new {
my $classname = shift;
my $self = {};
my $vals = shift || {};
$self->{start_token} = undef;
$self->{end_token} = undef;
$self->{endpoints} = undef;
if (UNIVERSAL::isa($vals,'HASH')) {
if (defined $vals->{start_token}) {
$self->{start_token} = $vals->{start_token};
}
if (defined $vals->{end_token}) {
$self->{end_token} = $vals->{end_token};
}
if (defined $vals->{endpoints}) {
$self->{endpoints} = $vals->{endpoints};
}
}
return bless ($self, $classname);
}
lib/Cassandra/Types.pm view on Meta::CPAN
}
last; };
/^3$/ && do{ if ($ftype == TType::LIST) {
{
my $_size35 = 0;
$self->{endpoints} = [];
my $_etype38 = 0;
$xfer += $input->readListBegin(\$_etype38, \$_size35);
for (my $_i39 = 0; $_i39 < $_size35; ++$_i39)
{
my $elem40 = undef;
$xfer += $input->readString(\$elem40);
push(@{$self->{endpoints}},$elem40);
}
$xfer += $input->readListEnd();
}
} else {
$xfer += $input->skip($ftype);
lib/Cassandra/Types.pm view on Meta::CPAN
if (defined $self->{end_token}) {
$xfer += $output->writeFieldBegin('end_token', TType::STRING, 2);
$xfer += $output->writeString($self->{end_token});
$xfer += $output->writeFieldEnd();
}
if (defined $self->{endpoints}) {
$xfer += $output->writeFieldBegin('endpoints', TType::LIST, 3);
{
$xfer += $output->writeListBegin(TType::STRING, scalar(@{$self->{endpoints}}));
{
foreach my $iter41 (@{$self->{endpoints}})
{
$xfer += $output->writeString($iter41);
}
}
$xfer += $output->writeListEnd();
view all matches for this distribution
view release on metacpan or search on metacpan
t/catalyst-action-rest-action-dispatch.t view on Meta::CPAN
# Should use the default serializer, YAML
my $t = Test::Rest->new( 'content_type' => 'text/plain' );
use_ok 'Catalyst::Test', 'Test::Catalyst::Action::REST';
foreach my $endpoint (qw/ test other_test /) {
foreach my $method (qw(GET DELETE POST PUT OPTIONS)) {
my $run_method = lc($method);
my $res;
if ( grep /$method/, qw(GET DELETE OPTIONS) ) {
$res = request( $t->$run_method( url => '/actions/' . $endpoint ) );
}
else {
$res = request(
$t->$run_method(
url => '/actions/' . $endpoint,
data => '',
)
);
}
ok( $res->is_success, "$method request succeeded" ) or warn Dumper($res);
view all matches for this distribution
view release on metacpan or search on metacpan
t/lib/Foo/Controller/Root.pm view on Meta::CPAN
push @{$c->stash->{body}}, 'explicit_detach';
$c->res->redirect('/success');
$c->detach;
}
sub explicit_detach_endpoint : Chained('explicit_detach') PathPart('endpoint') Args(0) {
my($self, $c) = @_;
push @{$c->stash->{body}}, 'endpoint';
return;
}
sub pitch_go : Chained('base') Args(0) ActionClass('DetachOnDie') {
my ( $self, $c ) = @_;
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Catalyst/ActionRole/Tabs.pm view on Meta::CPAN
[% END %]
</ul>
=head1 DESCRIPTION
This module allows to add 'Tab' attributes to action endpoints, and it
will automatically build a data structure suitable for rendering 'tabs'
to switch between the methods that share the same tab structure.
Although this was originally built to help with making tabbed interfaces,
it isn't limited to creating tabs, as it simply collects the information
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Catalyst/Authentication/Credential/OAuth.pm view on Meta::CPAN
Catalyst::Exception->throw( "Provider is not defined." )
unless defined $auth_info->{provider} || defined $self->providers->{ $auth_info->{provider} };
my $provider = $self->providers->{ $auth_info->{provider} };
for ( qw/ consumer_key consumer_secret request_token_endpoint access_token_endpoint user_auth_endpoint / ) {
Catalyst::Exception->throw( $_ . " is not defined for provider ". $auth_info->{provider} )
unless $provider->{$_};
}
my %defaults = (
lib/Catalyst/Authentication/Credential/OAuth.pm view on Meta::CPAN
my $request = Net::OAuth->request( 'access token' )->new(
%defaults,
token => $response->token,
token_secret => '',
request_url => $provider->{access_token_endpoint},
verifier => $c->req->params->{oauth_verifier},
);
$request->sign;
my $ua_response = $self->ua->request( GET $request->to_url );
lib/Catalyst/Authentication/Credential/OAuth.pm view on Meta::CPAN
return;
}
else {
my $request = Net::OAuth->request( 'request token' )->new(
%defaults,
request_url => $provider->{request_token_endpoint}
);
$request->sign;
my $ua_response = $self->ua->request( GET $request->to_url );
lib/Catalyst/Authentication/Credential/OAuth.pm view on Meta::CPAN
$request = Net::OAuth->request( 'user auth' )->new(
%defaults,
token => $response->token,
);
$c->res->redirect( $request->to_url( $provider->{user_auth_endpoint} ) );
}
}
lib/Catalyst/Authentication/Credential/OAuth.pm view on Meta::CPAN
class OAuth
<providers>
<example.com>
consumer_key my_app_key
consumer_secret my_app_secret
request_token_endpoint http://example.com/oauth/request_token
access_token_endpoint http://example.com/oauth/access_token
user_auth_endpoint http://example.com/oauth/authorize
</example.com>
</providers>
</credential>
</oauth>
</realms>
view all matches for this distribution
view release on metacpan or search on metacpan
t/Consumer/lib/TestApp/Controller/Root.pm view on Meta::CPAN
},
setup_url => $c->uri_for($c->req->path, {moo => "setup"}),
server_secret => $c->config->{startup_time},
);
# From your OpenID server endpoint:
my ( $type, $data ) = $nos->handle_page;
if ($type eq "redirect")
{
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Catalyst/Controller/DBIC/API.pm view on Meta::CPAN
item_root => 'data',
use_json_boolean => 1,
return_object => 1,
);
# Provides the following functional endpoints:
# /api/rpc/artist/create
# /api/rpc/artist/list
# /api/rpc/artist/id/[id]/delete
# /api/rpc/artist/id/[id]/update
=head1 DESCRIPTION
Easily provide common API endpoints based on your L<DBIx::Class> schema classes.
Module provides both RPC and REST interfaces to base functionality.
Uses L<Catalyst::Action::Serialize> and L<Catalyst::Action::Deserialize> to
serialize response and/or deserialise request.
=head1 OVERVIEW
This document describes base functionlity such as list, create, delete, update
and the setting of config attributes. L<Catalyst::Controller::DBIC::API::RPC>
and L<Catalyst::Controller::DBIC::API::REST> describe details of provided
endpoints to those base methods.
You will need to create a controller for each schema class you require API
endpoints for. For example if your schema has Artist and Track, and you want to
provide a RESTful interface to these, you should create
MyApp::Controller::API::REST::Artist and MyApp::Controller::API::REST::Track
which both subclass L<Catalyst::Controller::DBIC::API::REST>.
Similarly if you wanted to provide an RPC style interface then subclass
L<Catalyst::Controller::DBIC::API::RPC>. You then configure these individually
lib/Catalyst/Controller/DBIC/API.pm view on Meta::CPAN
Generally it's better to have one controller for each DBIC source with the
config hardcoded, but in some cases this isn't possible.
Note that the Chained, CaptureArgs and PathPart are just standard Catalyst
configuration parameters and that then endpoint specified in Chained - in this
case '/api/rpc/rpc_base' - must actually exist elsewhere in your application.
See L<Catalyst::DispatchType::Chained> for more details.
Below are explanations for various configuration parameters. Please see
L<Catalyst::Controller::DBIC::API::StaticArguments> for more details.
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Catalyst/Controller/ElasticSearch.pm view on Meta::CPAN
This controller base class provides some basic protection for your ElasticSearch
server. This will allow you to publish individual indices and types through
your Catalyst application. The controller will prevent malicious requests
such as huge size parameters or scripts.
ElasticSearch's C<_search> endpoint is very powerful. And with power comes great
responsibility. Instead of providing the vanilla search endpoint, it is recommeded
that you predefine searches that process only certain parameters. See L</DISABLING FEATURES>.
B<< Exposing ElasticSearch to the Internet is dangerous. MetaCPAN is doing it,
and this module is the result of what we've learned so far. >>
lib/Catalyst/Controller/ElasticSearch.pm view on Meta::CPAN
} or do { $c->detach("error", [500, $@]) };
}
=head1 ENDPOINTS
By default, this controller will create the following endpoints for a controller
named C<MyApp::Controller::Tweet>.
=head2 mapping
/twitter/tweet/_mapping
lib/Catalyst/Controller/ElasticSearch.pm view on Meta::CPAN
=head2 all
/twitter/tweet
This endpoint is equivalent to C</tweet/_search?q=*>.
=head2 search
/twitter/tweet/_search
This endpoint proxies to the search endpoint of ElasticSearch. However, it will
sanitize the query first.
=head1 ACCESS CONTROL
As with other controllers, you would do the access control in the C<auto>
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Catalyst/Controller/FlashRemoting.pm view on Meta::CPAN
Flash Remoting is RPC subsystem and that use AMF (Action Message Format) as message body format.
=head1 USAGE
At first, you need api gateway (endpoint) controller. Add AMFGateway attribute to catalyst action for that.
sub gateway :Local :AMFGateway { }
If you write above code in Root controller, then 'http://localhost:3000/gateway' is AMF Gateway url.
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Catalyst/Action/SOAP/DocumentLiteralWrapped.pm view on Meta::CPAN
__PACKAGE__->{config}{soap_action_prefix} = 'http://foo/bar/';
use base 'Catalyst::Controller::SOAP::DocumentLiteralWrapped';
# or
sub endpoint : Local ActionClass(SOAP::DocumentLiteralWrapped) { }
=head1 DESCRIPTION
Microsoft has defined a pseudo-standard for SOAP usage called
Document/Literal Wrapped. This standard is a deviation of both the
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Catalyst/ControllerRole/URI.pm view on Meta::CPAN
after 'register_action_methods', sub {
my ( $self, $app, @methods ) = @_;
my $class = ref $self;
my @endpoints = ();
my @types = @{ $app->dispatcher->dispatch_types ||+[] };
foreach my $type (@types) {
if(ref($type) eq 'Catalyst::DispatchType::Chained') {
foreach my $endpoint(@{ $type->{_endpoints} || [] }) {
if ($endpoint->class eq $class) {
push @endpoints, [$endpoint, $self->_generate_uri_pattern($type, $endpoint)];
}
}
}
}
lib/Catalyst/ControllerRole/URI.pm view on Meta::CPAN
my $col2_width = $avail_width - $col1_width;
my $paths = Text::SimpleTable->new(
[ $col1_width, 'uri' ], [ $col2_width, 'helper' ],
);
foreach my $endpoint_proto (@endpoints) {
my $endpoint = $endpoint_proto->[0];
my $uri = $endpoint_proto->[1];
my $path_args = '';
my $path_arg_count = 0;
if(my @path_args = @{$endpoint_proto->[2]||[]}) {
$path_arg_count = scalar(@path_args);
$path_args = join ',', @path_args if scalar(@path_args) > 0;
$path_args = "([$path_args])";
}
my $name = $endpoint->name;
my $private_path = $endpoint->private_path; $private_path =~s/^\///; $private_path =~s/\//_/g;
my $sub = sub {
my $self = shift;
my ($parts, @args) = $self->_normalize_uri_args(@_);
return $self->ctx->uri_for($self->action_for($name), $parts, @args);
};
lib/Catalyst/ControllerRole/URI.pm view on Meta::CPAN
{
no strict 'refs';
my $controller_helper = "${class}::${name}_uri";
*{$controller_helper} = Sub::Util::set_subname $controller_helper => $sub;
my $app_helper = "${app}::${private_path}_uri";
my $helper = $endpoint->private_path;
*{$app_helper} = Sub::Util::set_subname $app_helper => sub {
my $c = shift;
return $c->uri_for($c->dispatcher->get_action_by_path($helper), @_);
};
}
lib/Catalyst/ControllerRole/URI.pm view on Meta::CPAN
$app->log->debug("URI Helpers for: $class\n" . $paths->draw . "\n");
};
sub _generate_uri_pattern {
my ($self, $dispatcher, $endpoint) = @_;
my $args = $endpoint->list_extra_info->{Args};
my @parts;
if($endpoint->has_args_constraints) {
@parts = map { "{$_}" } $endpoint->all_args_constraints;
} elsif(defined $endpoint->attributes->{Args}) {
@parts = (defined($endpoint->attributes->{Args}[0]) ? (("*") x $args) : '...');
}
my @parents = ();
my $parent = "DUMMY";
my $extra = $dispatcher->_list_extra_http_methods($endpoint);
my $consumes = $dispatcher->_list_extra_consumes($endpoint);
my $scheme = $dispatcher->_list_extra_scheme($endpoint);
my $curr = $endpoint;
while ($curr) {
if (my $cap = $curr->list_extra_info->{CaptureArgs}) {
if($curr->has_captures_constraints) {
my $names = join '/', map { "{$_}" } $curr->all_captures_constraints;
unshift(@parts, $names);
view all matches for this distribution
view release on metacpan or search on metacpan
extends 'Catalyst::Controller';
sub root :At($controller/...) { }
sub endpoint :Via(root) At({id}) {
my ($self, $c, $id) = @_;
}
sub endpoin2 :Under(root) At({id}/{@}) {
my ($self, $c, @args) = @_;
extends 'Catalyst::Controller';
sub root Chained(/) PathPrefix CaptureArgs(0) { }
sub endpoint :Chained(root) PathPrefix('') Args(1) {
my ($self, $c, $id) = @_;
}
sub endpoin2 :Chained(root) PathPrefix('') Args {
my ($self, $c, @args) = @_;
view all matches for this distribution
view release on metacpan or search on metacpan
t/lib/TestApp/Controller/Action/Chained.pm view on Meta::CPAN
sub foo :PathPart('chained/foo') :CaptureArgs(1) :Chained('/') {
my ( $self, $c, @args ) = @_;
die "missing argument" unless @args;
die "more than 1 argument" if @args > 1;
}
sub endpoint :PathPart('end') :Chained('/action/chained/foo') :Args(1) { }
#
# Parent/child test with two args each
#
sub foo2 :PathPart('chained/foo2') :CaptureArgs(2) :Chained('/') { }
sub endpoint2 :PathPart('end2') :Chained('/action/chained/foo2') :Args(2) { }
#
# Relative specification of parent action
#
sub bar :PathPart('chained/bar') :Chained('/') :CaptureArgs(0) { }
sub finale :PathPart('') :Chained('bar') :Args { }
#
# three chain with concurrent endpoints
#
sub one :PathPart('chained/one') :Chained('/') :CaptureArgs(1) { }
sub two :PathPart('two') :Chained('/action/chained/one') :CaptureArgs(2) { }
sub three_end :PathPart('three') :Chained('two') :Args(3) { }
sub one_end :PathPart('chained/one') :Chained('/') :Args(1) { }
t/lib/TestApp/Controller/Action/Chained.pm view on Meta::CPAN
sub priority_c2 :PathPart('') :Chained('priority_c1') { }
sub priority_c2_xyz :PathPart('xyz') :Chained('priority_c1') { }
#
# Optional specification of :Args in endpoint
#
sub opt_args :PathPart('chained/opt_args') :Chained('/') { }
#
# Optional PathPart test -> /chained/optpp/*/opt_pathpart/*
view all matches for this distribution
view release on metacpan or search on metacpan
t/lib/TestApp/Controller/Action/Chained.pm view on Meta::CPAN
#
# Simple parent/child action test
#
sub foo :PathPart('chained/foo') :CaptureArgs(1) :Chained('/') { }
sub endpoint :PathPart('end') :Chained('/action/chained/foo') :Args(1) { }
#
# Parent/child test with two args each
#
sub foo2 :PathPart('chained/foo2') :CaptureArgs(2) :Chained('/') { }
sub endpoint2 :PathPart('end2') :Chained('/action/chained/foo2') :Args(2) { }
#
# Relative specification of parent action
#
sub bar :PathPart('chained/bar') :Chained('/') :CaptureArgs(0) { }
sub finale :PathPart('') :Chained('bar') :Args { }
#
# three chain with concurrent endpoints
#
sub one :PathPart('chained/one') :Chained('/') :CaptureArgs(1) { }
sub two :PathPart('two') :Chained('/action/chained/one') :CaptureArgs(2) { }
sub three_end :PathPart('three') :Chained('two') :Args(3) { }
sub one_end :PathPart('chained/one') :Chained('/') :Args(1) { }
t/lib/TestApp/Controller/Action/Chained.pm view on Meta::CPAN
sub priority_c2 :PathPart('') :Chained('priority_c1') { }
sub priority_c2_xyz :PathPart('xyz') :Chained('priority_c1') { }
#
# Optional specification of :Args in endpoint
#
sub opt_args :PathPart('chained/opt_args') :Chained('/') { }
#
# Optional PathPart test -> /chained/optpp/*/opt_pathpart/*
view all matches for this distribution
view release on metacpan or search on metacpan
t/lib/TestApp/Controller/Action/Chained.pm view on Meta::CPAN
#
# Simple parent/child action test
#
sub foo :PathPart('chained/foo') :CaptureArgs(1) :Chained('/') { }
sub endpoint :PathPart('end') :Chained('/action/chained/foo') :Args(1) { }
#
# Parent/child test with two args each
#
sub foo2 :PathPart('chained/foo2') :CaptureArgs(2) :Chained('/') { }
sub endpoint2 :PathPart('end2') :Chained('/action/chained/foo2') :Args(2) { }
#
# Relative specification of parent action
#
sub bar :PathPart('chained/bar') :Chained('/') :CaptureArgs(0) { }
sub finale :PathPart('') :Chained('bar') :Args { }
#
# three chain with concurrent endpoints
#
sub one :PathPart('chained/one') :Chained('/') :CaptureArgs(1) { }
sub two :PathPart('two') :Chained('/action/chained/one') :CaptureArgs(2) { }
sub three_end :PathPart('three') :Chained('two') :Args(3) { }
sub one_end :PathPart('chained/one') :Chained('/') :Args(1) { }
t/lib/TestApp/Controller/Action/Chained.pm view on Meta::CPAN
sub priority_c2 :PathPart('') :Chained('priority_c1') { }
sub priority_c2_xyz :PathPart('xyz') :Chained('priority_c1') { }
#
# Optional specification of :Args in endpoint
#
sub opt_args :PathPart('chained/opt_args') :Chained('/') { }
#
# Optional PathPart test -> /chained/optpp/*/opt_pathpart/*
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Catalyst/Manual/Cookbook.pod view on Meta::CPAN
$c->stash->{track} = $self->stash->{cd}->find_track_by_vol_and_track_no(
$c->stash->{volume}, $track_no
);
}
Note that adding other actions (i.e. chain endpoints) which operate on a track
is simply a matter of adding a new sub to CD::Controller - no code is duplicated,
even though there are two different methods of looking up a track.
This technique can be expanded as needed to fulfil your requirements - for example,
if you inherit the first action of a chain from a base class, then mixing in a
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Catalyst/Model/Bitcoin.pm view on Meta::CPAN
my ($c, $arg_ref) = @_;
croak "->config->{uri} must be set for $class\n"
unless $self->{uri};
$self->api( Finance::Bitcoin::API->new( endpoint => $self->{uri} ) );
$self->wallet( Finance::Bitcoin::Wallet->new( $self->api ) );
return $self;
}
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Catalyst/Helper/Model/JabberRPC.pm view on Meta::CPAN
The same as the B<identauth> arg. passed to L<Jabber::RPC::Client>.
=item * C<jrpc.myserver.org/rpc-server>
The same as the B<endpoint> arg. passed to L<Jabber::RPC::Client>.
=back
=head1 METHODS
lib/Catalyst/Helper/Model/JabberRPC.pm view on Meta::CPAN
Makes the JabberRPC model class.
=cut
sub mk_compclass {
my ($self, $helper, $server, $identauth, $endpoint) = @_;
$helper->{server} = $server || '';
$helper->{identauth} = $identauth || '';
$helper->{endpoint} = $endpoint || '';
$helper->render_file('modelclass', $helper->{file});
return 1;
}
lib/Catalyst/Helper/Model/JabberRPC.pm view on Meta::CPAN
use base 'Catalyst::Model::JabberRPC';
__PACKAGE__->config(
server => '[% server %]',
identauth => '[% identauth %]',
endpoint => '[% endpoint %]',
# For more options take a look at L<Jabber::RPC::Client>.
);
=head1 NAME
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Catalyst/Plugin/ActionPaths.pm view on Meta::CPAN
}
}
elsif (ref $dt eq 'Catalyst::DispatchType::Chained')
{
# taken from Catalyst::DispatchType::Chained
ENDPOINT: foreach my $endpoint (
sort { $a->reverse cmp $b->reverse }
@{ $dt->_endpoints }
) {
my $args = $endpoint->list_extra_info->{Args};
my @parts = (defined($endpoint->attributes->{Args}[0]) ? (("*") x $args) : '...');
my @parents = ();
my $parent = "DUMMY";
my $extra = $dt->_list_extra_http_methods($endpoint);
my $consumes = $dt->_list_extra_consumes($endpoint);
my $scheme = $dt->_list_extra_scheme($endpoint);
my $curr = $endpoint;
my $action = $endpoint;
while ($curr) {
if (my $cap = $curr->list_extra_info->{CaptureArgs}) {
unshift(@parts, (("*") x $cap));
}
if (my $pp = $curr->attributes->{PathPart}) {
lib/Catalyst/Plugin/ActionPaths.pm view on Meta::CPAN
$name = "-> ${name}";
}
push(@rows, [ '', $name ]);
}
if($endpoint->has_args_constraints) {
my $tc = join ',', @{$endpoint->args_constraints};
$endpoint .= " ($tc)";
} else {
$endpoint .= defined($endpoint->attributes->{Args}[0]) ? " ($args)" : " (...)";
}
push(@rows, [ '', (@rows ? "=> " : '').($extra ? "$extra " : ''). ($scheme ? "$scheme: ":'')."/${endpoint}". ($consumes ? " :$consumes":"" ) ]);
my @display_parts = map { $_ =~s/%([0-9A-Fa-f]{2})/chr(hex($1))/eg; decode_utf8 $_ } @parts;
$rows[0][0] = join('/', '', @display_parts) || '/';
$action->{path} = $rows[0][0];
push @actions, $action;
}
view all matches for this distribution
view release on metacpan or search on metacpan
libcatalyst-plugin-autocrud-perl (0.71_02) UNRELEASED; urgency=low
* Rename all uses of lf to cpac (legacy ListFramework references)
* Make stash use much more polite - use cpac_* namespacing
* Add dumpmeta_html endpoint which dumps metadata to HTML
* Support for dispatched storage backends via site_conf backend
* Add http_charset param to override the (new) default of utf-8
* Filter output for HTML entities in skinny frontnend
* DBIC ResultSource::View results in a CUD operations being disabled
* [temporary] fix for rt.cpan #56250 Views have no primary key(s)
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Catalyst/Plugin/CSRFToken.pm view on Meta::CPAN
integrity="sha384-..."
crossorigin="anonymous"
></script>
<script>
$.ajax({
url: '/some/endpoint',
type: 'POST',
headers: {
'X-CSRF-Token': '[% c.csrf_token(form_id=>"your_form_id") %]'
},
data: {
view all matches for this distribution
view release on metacpan or search on metacpan
t/lib/TestApp/Controller/Action/Chained.pm view on Meta::CPAN
#
# Simple parent/child action test
#
sub foo :PathPart('chained/foo') :CaptureArgs(1) :Chained('/') {
}
sub endpoint :PathPart('end') :Chained('/action/chained/foo') :Args(1) { }
#
# Parent/child test with two args each
#
sub foo2 :PathPart('chained/foo2') :CaptureArgs(2) :Chained('/') { }
sub endpoint2 :PathPart('end2') :Chained('/action/chained/foo2') :Args(2) { }
#
# three chain with concurrent endpoints
#
sub one :PathPart('chained/one') :Chained('/') :CaptureArgs(1) { }
sub two :PathPart('two') :Chained('/action/chained/one') :CaptureArgs(2) { }
sub three_end :PathPart('three') :Chained('two') :Args(3) { }
view all matches for this distribution
view release on metacpan or search on metacpan
sub midpoint :Chained('set_model_by_return') PathPart('') CaptureArgs(0) {
my ($self, $c) = @_;
}
sub endpoint :Chained('midpoint') PathPart('') Args(0) {
my ($self, $c) = @_;
$c->res->body(ref $c->model);
}
sub set_view_by_return :Chained(/) CaptureArgs(0) {
sub midpoint2 :Chained('set_view_by_return') PathPart('') CaptureArgs(0) {
my ($self, $c) = @_;
}
sub endpoint2 :Chained('midpoint2') PathPart('') Args(0) {
my ($self, $c) = @_;
$c->res->body(ref $c->view);
}
package MyApp;
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Catalyst/Plugin/ForwardChained.pm view on Meta::CPAN
# In your application class
use Catalyst qw/ ForwardChained /;
# ... somwhere else:
$c->forward_to_chained( [ qw/ chained endpoint /, [ qw/ args / ] );
$c->forward_to_chained( 'chained/endpoint', [ qw/ args / ] );
=head2 Example 1
Having some controller:
lib/Catalyst/Plugin/ForwardChained.pm view on Meta::CPAN
$VERSION = '0.03';
=head2 forward_to_chained
forwards to a certain chained action endpoint ..
$c->forward_to_chained( "some/path", [ qw/ arg1 arg2 arg3 / ] );
$c->forward_to_chained( [qw/ some path /], [ qw/ arg1 arg2 arg3 / ] );
=cut
lib/Catalyst/Plugin/ForwardChained.pm view on Meta::CPAN
return ;
}
=head2 get_chained_action_endpoints
returns array or arrayref of endpoints.. to help you find the one you need
my @endpoints = $c->get_chained_action_endpoints;
my $endpoints_ref = $c->get_chained_action_endpoints;
=cut
sub get_chained_action_endpoints {
my ( $c ) = @_;
my $actions_ref = $c->dispatcher->action_hash;
my @endpoints =
sort
grep {
defined $actions_ref->{ $_ }->{ attributes } &&
ref $actions_ref->{ $_ }->{ attributes }->{ Chained }
}
grep { ! /(?:^|\/)_[A-Z]+$/ } keys %{ $actions_ref }
;
return wantarray ? @endpoints : \@endpoints;
}
view all matches for this distribution
view release on metacpan or search on metacpan
examples/lib/Example/JSONRPC/Controller/Root.pm view on Meta::CPAN
BEGIN { extends 'Catalyst::Controller' }
__PACKAGE__->config( namespace => '' );
# A JSON-RPC endpoint. Handlers are registered per request (cheap here); a real
# app would register them once at setup. Each handler gets the request's params
# and returns the result; an unregistered method yields a -32601 error.
sub rpc :Path('/rpc') :Args(0) {
my ( $self, $c ) = @_;
$c->jsonrpc_register( echo => sub ($p) { $p } );
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Catalyst/Plugin/JSONRPC.pm view on Meta::CPAN
=over 4
=item $c->json_rpc(%attrs)
Call this method from a controller action to set it up as a endpoint
for RPC methods in the same class.
Supported attributes:
=over 8
lib/Catalyst/Plugin/JSONRPC.pm view on Meta::CPAN
This module uses C<Remote> attribute, which indicates that the action
can be dispatched through RPC mechanisms. You can use this C<Remote>
attribute and integrate JSON-RPC and XML-RPC together, for example:
sub xmlrpc_endpoint : Regexp('^xml-rpc$') {
my($self, $c) = @_;
$c->xmlrpc;
}
sub jsonrpc_endpoint : Regexp('^json-rpc$') {
my($self, $c) = @_;
$c->json_rpc;
}
sub add : Remote {
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Catalyst/Plugin/MCP.pm view on Meta::CPAN
+Catalyst::Plugin::JSONRPC::Server
+Catalyst::Plugin::MCP
/;
__PACKAGE__->setup;
# in a controller action mounted at your MCP endpoint
sub mcp :Path('/mcp') :Args(0) {
my ( $self, $c ) = @_;
$c->mcp_register_provider( $c->model('MCP::Resources') );
$c->mcp_register_provider( $c->model('MCP::Tools') );
$c->mcp_dispatch;
lib/Catalyst/Plugin/MCP.pm view on Meta::CPAN
=head1 SECURITY
B<This plugin ships no authentication and no C<Origin> validation, and
C<mcp_dispatch> does not add any.> A C<tools/call> runs your provider's code,
so an endpoint mounted as in the SYNOPSIS executes tools for anyone who can
POST to it. Guarding it is the application's job, and both of these are on you:
=over
=item Authenticate the endpoint
The MCP Streamable HTTP transport says servers SHOULD authenticate connections.
Put your own authentication (a Catalyst authentication plugin, an C<auto>
action, or middleware) in front of C<mcp_dispatch>, and let the request reach it
only once it is authorised. Consider also what a provider is allowed to reach:
the engine does not scope tools or resources to a user.
=item Validate the C<Origin> header
The transport says servers MUST validate C<Origin> on incoming connections, to
stop a browser on another site from driving your endpoint via DNS rebinding.
Check it against an allow-list and reject anything else before dispatching.
=back
Binding to localhost rather than C<0.0.0.0> is worth it for a local server, but
view all matches for this distribution
view release on metacpan or search on metacpan
examples/lib/Example/OAuthAS.pm view on Meta::CPAN
store => 'Store', # resolved via $c->model('Store')
signing_key => 'example-authorization-server-signing-key-0123456789',
issuer => 'http://localhost:5000',
resource => 'urn:example:resource',
scopes_supported => [ 'example:read', 'example:write' ],
authorize_endpoint => 'http://localhost:5000/oauth/authorize',
token_endpoint => 'http://localhost:5000/oauth/token',
registration_endpoint => 'http://localhost:5000/oauth/register',
},
);
# The plugin calls this after a valid /authorize request. A real app would render
# a login + consent page; this example auto-consents as a fixed demo user, mints
view all matches for this distribution
view release on metacpan or search on metacpan
examples/README.md view on Meta::CPAN
# OAuth2 resource-server example
A minimal Catalyst app that protects a single endpoint, `/api/whoami`, with
`Catalyst::Plugin::OAuth2::ResourceServer`. The client is self-contained: it
mints its own demo bearer token with `Crypt::JWT` (HS256, using the same
signing key configured in the app), so no separate authorization server is
needed to try this out.
view all matches for this distribution
view release on metacpan or search on metacpan
t/auth-code-flow-IT/MyProviderApp/app.pl view on Meta::CPAN
# provider server routes
get('/wellknown' => sub {
my $c = shift;
my %url = (
authorization_endpoint => '/authorize',
end_session_endpoint => '/logout',
token_endpoint => '/token',
jwks_uri => '/jwks',
);
$c->render(json => {map { $_ => $url{$_} } keys %url});
});
# get '/authorize' in MyCatalystApp/Controller/Root.pm (ugly but necessary)
view all matches for this distribution