[Catalyst-commits] r7163 - in trunk/examples/RestYUI: . data db lib
lib/AdventREST lib/AdventREST/Controller lib/AdventREST/Model
lib/AdventREST/Schema root root/static root/static/images script t
jshirley at dev.catalyst.perl.org
jshirley at dev.catalyst.perl.org
Mon Nov 26 23:07:04 GMT 2007
Author: jshirley
Date: 2007-11-26 23:07:03 +0000 (Mon, 26 Nov 2007)
New Revision: 7163
Added:
trunk/examples/RestYUI/Changes
trunk/examples/RestYUI/Makefile.PL
trunk/examples/RestYUI/README
trunk/examples/RestYUI/adventrest.yml
trunk/examples/RestYUI/data/
trunk/examples/RestYUI/data/new-user.yml
trunk/examples/RestYUI/data/update-user.datadumper
trunk/examples/RestYUI/db.sql
trunk/examples/RestYUI/db/
trunk/examples/RestYUI/db/adventrest.db
trunk/examples/RestYUI/lib/
trunk/examples/RestYUI/lib/AdventREST.pm
trunk/examples/RestYUI/lib/AdventREST/
trunk/examples/RestYUI/lib/AdventREST/Controller/
trunk/examples/RestYUI/lib/AdventREST/Controller/Root.pm
trunk/examples/RestYUI/lib/AdventREST/Controller/User.pm
trunk/examples/RestYUI/lib/AdventREST/Model/
trunk/examples/RestYUI/lib/AdventREST/Model/DB.pm
trunk/examples/RestYUI/lib/AdventREST/Schema.pm
trunk/examples/RestYUI/lib/AdventREST/Schema/
trunk/examples/RestYUI/lib/AdventREST/Schema/User.pm
trunk/examples/RestYUI/lib/AdventREST/View/
trunk/examples/RestYUI/root/
trunk/examples/RestYUI/root/favicon.ico
trunk/examples/RestYUI/root/static/
trunk/examples/RestYUI/root/static/images/
trunk/examples/RestYUI/root/static/images/btn_120x50_built.png
trunk/examples/RestYUI/root/static/images/btn_120x50_built_shadow.png
trunk/examples/RestYUI/root/static/images/btn_120x50_powered.png
trunk/examples/RestYUI/root/static/images/btn_120x50_powered_shadow.png
trunk/examples/RestYUI/root/static/images/btn_88x31_built.png
trunk/examples/RestYUI/root/static/images/btn_88x31_built_shadow.png
trunk/examples/RestYUI/root/static/images/btn_88x31_powered.png
trunk/examples/RestYUI/root/static/images/btn_88x31_powered_shadow.png
trunk/examples/RestYUI/root/static/images/catalyst_logo.png
trunk/examples/RestYUI/script/
trunk/examples/RestYUI/script/adventrest_cgi.pl
trunk/examples/RestYUI/script/adventrest_create.pl
trunk/examples/RestYUI/script/adventrest_fastcgi.pl
trunk/examples/RestYUI/script/adventrest_server.pl
trunk/examples/RestYUI/script/adventrest_test.pl
trunk/examples/RestYUI/t/
trunk/examples/RestYUI/t/01app.t
Modified:
trunk/examples/RestYUI/
Log:
Property changes on: trunk/examples/RestYUI
___________________________________________________________________
Name: svk:merge
+ 4ad37cd2-5fec-0310-835f-b3785c72a374:/trunk/examples/AdventREST:5728
Added: trunk/examples/RestYUI/Changes
===================================================================
--- trunk/examples/RestYUI/Changes (rev 0)
+++ trunk/examples/RestYUI/Changes 2007-11-26 23:07:03 UTC (rev 7163)
@@ -0,0 +1,2 @@
+0.01 2006-12-05 21:45:06
+ - Initial Revision
Added: trunk/examples/RestYUI/Makefile.PL
===================================================================
--- trunk/examples/RestYUI/Makefile.PL (rev 0)
+++ trunk/examples/RestYUI/Makefile.PL 2007-11-26 23:07:03 UTC (rev 7163)
@@ -0,0 +1,17 @@
+use inc::Module::Install;
+
+name 'AdventREST';
+all_from 'lib/AdventREST.pm';
+
+requires 'Catalyst' => '5.7003';
+requires 'Catalyst::Plugin::ConfigLoader';
+requires 'Catalyst::Plugin::Static::Simple';
+requires 'Catalyst::Action::REST', "0.31";
+requires 'Catalyst::Model::DBIC::Schema';
+requires 'DBD::SQLite';
+requires 'YAML::Syck';
+catalyst;
+
+install_script glob('script/*.pl');
+auto_install;
+WriteAll;
Added: trunk/examples/RestYUI/README
===================================================================
--- trunk/examples/RestYUI/README (rev 0)
+++ trunk/examples/RestYUI/README 2007-11-26 23:07:03 UTC (rev 7163)
@@ -0,0 +1 @@
+Run script/adventrest_server.pl to test the application.
Added: trunk/examples/RestYUI/adventrest.yml
===================================================================
--- trunk/examples/RestYUI/adventrest.yml (rev 0)
+++ trunk/examples/RestYUI/adventrest.yml 2007-11-26 23:07:03 UTC (rev 7163)
@@ -0,0 +1,9 @@
+---
+name: AdventREST
+Model::DB:
+ schema_class: AdventREST::Schema
+ connect_info:
+ - DBI:SQLite:dbname=__path_to(db/adventrest.db)__
+ - ""
+ - ""
+
Added: trunk/examples/RestYUI/data/new-user.yml
===================================================================
--- trunk/examples/RestYUI/data/new-user.yml (rev 0)
+++ trunk/examples/RestYUI/data/new-user.yml 2007-11-26 23:07:03 UTC (rev 7163)
@@ -0,0 +1,4 @@
+---
+user_id: adam
+fullname: Adam Jacob
+description: Another Catalyst Monkey
Added: trunk/examples/RestYUI/data/update-user.datadumper
===================================================================
--- trunk/examples/RestYUI/data/update-user.datadumper (rev 0)
+++ trunk/examples/RestYUI/data/update-user.datadumper 2007-11-26 23:07:03 UTC (rev 7163)
@@ -0,0 +1,5 @@
+{
+ user_id => "adam",
+ fullname => "Adam Jacob",
+ description => "Catalyst::Action::REST rules!",
+}
Added: trunk/examples/RestYUI/db/adventrest.db
===================================================================
(Binary files differ)
Property changes on: trunk/examples/RestYUI/db/adventrest.db
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/examples/RestYUI/db.sql
===================================================================
--- trunk/examples/RestYUI/db.sql (rev 0)
+++ trunk/examples/RestYUI/db.sql 2007-11-26 23:07:03 UTC (rev 7163)
@@ -0,0 +1,5 @@
+CREATE TABLE user (
+ user_id TYPE text NOT NULL PRIMARY KEY,
+ fullname TYPE text NOT NULL,
+ description TYPE text NOT NULL
+);
Added: trunk/examples/RestYUI/lib/AdventREST/Controller/Root.pm
===================================================================
--- trunk/examples/RestYUI/lib/AdventREST/Controller/Root.pm (rev 0)
+++ trunk/examples/RestYUI/lib/AdventREST/Controller/Root.pm 2007-11-26 23:07:03 UTC (rev 7163)
@@ -0,0 +1,50 @@
+package AdventREST::Controller::Root;
+
+use strict;
+use warnings;
+use base 'Catalyst::Controller';
+
+#
+# Sets the actions in this controller to be registered with no prefix
+# so they function identically to actions created in MyApp.pm
+#
+__PACKAGE__->config->{namespace} = '';
+
+=head1 NAME
+
+AdventREST::Controller::Root - Root Controller for AdventREST
+
+=head1 DESCRIPTION
+
+Simply returns 404.
+
+=head1 METHODS
+
+=cut
+
+=head2 default
+
+Returns 404, and directs you to /users.
+
+=cut
+
+sub default : Private {
+ my ( $self, $c ) = @_;
+
+ $c->response->status(404);
+ $c->response->content_type('text/plain');
+ $c->response->body("Try going to " . $c->uri_for('/user'));
+}
+
+=head1 AUTHOR
+
+Adam Jacob
+
+=head1 LICENSE
+
+This library is free software, you can redistribute it and/or modify
+it under the same terms as Perl itself.
+
+=cut
+
+1;
Added: trunk/examples/RestYUI/lib/AdventREST/Controller/User.pm
===================================================================
--- trunk/examples/RestYUI/lib/AdventREST/Controller/User.pm (rev 0)
+++ trunk/examples/RestYUI/lib/AdventREST/Controller/User.pm 2007-11-26 23:07:03 UTC (rev 7163)
@@ -0,0 +1,188 @@
+package AdventREST::Controller::User;
+
+use strict;
+use warnings;
+use base 'Catalyst::Controller::REST';
+
+=head1 NAME
+
+AdventREST::Controller::User - Catalyst Advent Calendar REST Controller
+
+=head1 DESCRIPTION
+
+This is the Catalyst Advent Calendar 2006 REST example controller.
+It shows how to implement a basic RESTful Web Service in Catalyst using
+L<Catalyst::Controller::REST>
+
+=head1 METHODS
+
+=cut
+
+=head2 user_list :Path('/user') :ActionClass('REST')
+
+This method sets up the /user url, which lists all of our users. Requests
+will be dispatched to user_list_METHOD.
+
+=cut
+
+sub user_list : Path('/user') :Args(0) ActionClass('REST') {
+}
+
+=head2 user_list_GET
+
+Handles GET requests on '/user'. Returns a hash of users, with URIs for
+each one. Returns a 200 OK with the hash of users.
+
+=cut
+
+sub user_list_GET {
+ my ( $self, $c ) = @_;
+
+ my %user_list;
+ my $user_rs = $c->model('DB::User')->search;
+ while ( my $user_row = $user_rs->next ) {
+ $user_list{ $user_row->user_id } =
+ $c->uri_for( '/user/' . $user_row->user_id )->as_string;
+ }
+ $self->status_ok( $c, entity => \%user_list );
+}
+
+=head2 single_user :Path('/user') :Args(1) :ActionClass('REST')
+
+Sets up requests to '/user/*'. The only argument is a user_id, which we
+use to perform a quick lookup for the user, storing the data in the stash
+for use in later methods.
+
+=cut
+
+sub single_user : Path('/user') :Args(1) : ActionClass('REST') {
+ my ( $self, $c, $user_id ) = @_;
+
+ $c->stash->{'user'} = $c->model('DB::User')->find($user_id);
+}
+
+=head2 single_user_POST
+
+Creates or updates a user in the database. Returns 400 BAD REQUEST if the
+data submitted is incomplete, or if an attempt is made to create a resource
+at a bad URI. Returns 200 OK if the user was modified, and 201 CREATED if
+it was created.
+
+=cut
+
+sub single_user_POST {
+ my ( $self, $c, $user_id ) = @_;
+
+ my $new_user_data = $c->req->data;
+ if ( !defined($new_user_data) ) {
+ return $self->status_bad_request( $c,
+ message => "You must provide a user to create or modify!" );
+ }
+
+ if ( $new_user_data->{'user_id'} ne $user_id ) {
+ return $self->status_bad_request( $c,
+ message => "Cannot create or modify user "
+ . $new_user_data->{'user_id'} . " at "
+ . $c->req->uri->as_string
+ . "; the user_id does not match!" );
+ }
+
+ foreach my $required (qw(user_id fullname description)) {
+ return $self->status_bad_request( $c,
+ message => "Missing required field: " . $required )
+ if !exists( $new_user_data->{$required} );
+ }
+ my $user = $c->model('DB::User')->update_or_create(
+ user_id => $new_user_data->{'user_id'},
+ fullname => $new_user_data->{'fullname'},
+ description => $new_user_data->{'description'},
+ );
+ my $return_entity = {
+ user_id => $user->user_id,
+ fullname => $user->fullname,
+ description => $user->description,
+ };
+
+ if ( $c->stash->{'user'} ) {
+ $self->status_ok( $c, entity => $return_entity, );
+ } else {
+ $self->status_created(
+ $c,
+ location => $c->req->uri->as_string,
+ entity => $return_entity,
+ );
+ }
+}
+
+=head2 single_user_PUT
+
+The same as single_user_POST. This is often the case in REST, since a PUT request should modify the entry it describes if it already exists.
+
+=cut
+
+*single_user_PUT = *single_user_POST;
+
+=head2 single_user_GET
+
+Returns a user.
+
+=cut
+
+sub single_user_GET {
+ my ( $self, $c, $user_id ) = @_;
+
+ my $user = $c->stash->{'user'};
+ if ( defined($user) ) {
+ $self->status_ok(
+ $c,
+ entity => {
+ user_id => $user->user_id,
+ fullname => $user->fullname,
+ description => $user->description,
+ }
+ );
+ } else {
+ $self->status_not_found( $c,
+ message => "Could not find User $user_id!" );
+ }
+}
+
+=head2 single_user_DELETE
+
+Removes a user from the database. Returns 200 OK with the deleted entity
+on success, or 404 NOT FOUND if the user doesn't exist.
+
+=cut
+
+sub single_user_DELETE {
+ my ( $self, $c, $user_id ) = @_;
+
+ my $user = $c->stash->{'user'};
+ if ( defined($user) ) {
+ $user->delete;
+ $self->status_ok(
+ $c,
+ entity => {
+ user_id => $user->user_id,
+ fullname => $user->fullname,
+ description => $user->description,
+ }
+ );
+ } else {
+ $self->status_not_found( $c,
+ message => "Cannot delete non-existent user $user_id!" );
+ }
+}
+
+=head1 AUTHOR
+
+Adam Jacob L<mailto:adam at stalecoffee.org>
+
+=head1 LICENSE
+
+This library is free software, you can redistribute it and/or modify
+it under the same terms as Perl itself.
+
+=cut
+
+1;
Added: trunk/examples/RestYUI/lib/AdventREST/Model/DB.pm
===================================================================
--- trunk/examples/RestYUI/lib/AdventREST/Model/DB.pm (rev 0)
+++ trunk/examples/RestYUI/lib/AdventREST/Model/DB.pm 2007-11-26 23:07:03 UTC (rev 7163)
@@ -0,0 +1,33 @@
+package AdventREST::Model::DB;
+
+use strict;
+use base 'Catalyst::Model::DBIC::Schema';
+
+__PACKAGE__->config(
+ schema_class => 'AdventREST::Schema',
+);
+
+=head1 NAME
+
+AdventREST::Model::DB - Catalyst DBIC Schema Model
+
+=head1 SYNOPSIS
+
+See L<AdventREST>
+
+=head1 DESCRIPTION
+
+L<Catalyst::Model::DBIC::Schema> Model using schema L<AdventREST::Schema>
+
+=head1 AUTHOR
+
+Adam Jacob L<mailto:adam at stalecoffee.org>
+
+=head1 LICENSE
+
+This library is free software, you can redistribute it and/or modify
+it under the same terms as Perl itself.
+
+=cut
+
+1;
Added: trunk/examples/RestYUI/lib/AdventREST/Schema/User.pm
===================================================================
--- trunk/examples/RestYUI/lib/AdventREST/Schema/User.pm (rev 0)
+++ trunk/examples/RestYUI/lib/AdventREST/Schema/User.pm 2007-11-26 23:07:03 UTC (rev 7163)
@@ -0,0 +1,16 @@
+#
+# AdventREST::Schema::User.pm
+#
+# $Id: $
+
+package AdventREST::Schema::User;
+
+use base qw/DBIx::Class/;
+
+__PACKAGE__->load_components(qw/Core/);
+__PACKAGE__->table('user');
+__PACKAGE__->add_columns(qw/user_id fullname description/);
+__PACKAGE__->set_primary_key('user_id');
+
+1;
+
Added: trunk/examples/RestYUI/lib/AdventREST/Schema.pm
===================================================================
--- trunk/examples/RestYUI/lib/AdventREST/Schema.pm (rev 0)
+++ trunk/examples/RestYUI/lib/AdventREST/Schema.pm 2007-11-26 23:07:03 UTC (rev 7163)
@@ -0,0 +1,12 @@
+#
+# AdventREST::Schema.pm
+#
+# $Id: $
+
+package AdventREST::Schema;
+use base qw/DBIx::Class::Schema/;
+
+__PACKAGE__->load_classes(qw/User/);
+
+1;
+
Added: trunk/examples/RestYUI/lib/AdventREST.pm
===================================================================
--- trunk/examples/RestYUI/lib/AdventREST.pm (rev 0)
+++ trunk/examples/RestYUI/lib/AdventREST.pm 2007-11-26 23:07:03 UTC (rev 7163)
@@ -0,0 +1,66 @@
+package AdventREST;
+
+use strict;
+use warnings;
+
+use Catalyst::Runtime '5.70';
+
+# Set flags and add plugins for the application
+#
+# -Debug: activates the debug mode for very useful log messages
+# ConfigLoader: will load the configuration from a YAML file in the
+# application's home directory
+# Static::Simple: will serve static files from the application's root
+# directory
+
+use Catalyst qw/-Debug ConfigLoader Static::Simple/;
+
+our $VERSION = '0.01';
+
+# Configure the application.
+#
+# Note that settings in AdventREST.yml (or other external
+# configuration file that you set up manually) take precedence
+# over this when using ConfigLoader. Thus configuration
+# details given here can function as a default configuration,
+# with a external configuration file acting as an override for
+# local deployment.
+
+__PACKAGE__->config(
+ name => 'AdventREST'
+);
+
+# Start the application
+__PACKAGE__->setup;
+
+
+=head1 NAME
+
+AdventREST - Catalyst::Action::REST Example for Advent 2006
+
+=head1 SYNOPSIS
+
+ script/adventrest_server.pl
+
+=head1 DESCRIPTION
+
+This is the sample Web Service to go along with the Catalyst Advent entry on
+L<Catalyst::Action::REST>. You probably want to see
+L<AdventREST::Controller::User> for the real meat.
+
+=head1 SEE ALSO
+
+L<AdventREST::Controller::User>, L<Catalyst>
+
+=head1 AUTHOR
+
+Adam Jacob L<mailto:adam at stalecoffee.org>
+
+=head1 LICENSE
+
+This library is free software, you can redistribute it and/or modify
+it under the same terms as Perl itself.
+
+=cut
+
+1;
Added: trunk/examples/RestYUI/root/favicon.ico
===================================================================
(Binary files differ)
Property changes on: trunk/examples/RestYUI/root/favicon.ico
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/examples/RestYUI/root/static/images/btn_120x50_built.png
===================================================================
(Binary files differ)
Property changes on: trunk/examples/RestYUI/root/static/images/btn_120x50_built.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/examples/RestYUI/root/static/images/btn_120x50_built_shadow.png
===================================================================
(Binary files differ)
Property changes on: trunk/examples/RestYUI/root/static/images/btn_120x50_built_shadow.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/examples/RestYUI/root/static/images/btn_120x50_powered.png
===================================================================
(Binary files differ)
Property changes on: trunk/examples/RestYUI/root/static/images/btn_120x50_powered.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/examples/RestYUI/root/static/images/btn_120x50_powered_shadow.png
===================================================================
(Binary files differ)
Property changes on: trunk/examples/RestYUI/root/static/images/btn_120x50_powered_shadow.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/examples/RestYUI/root/static/images/btn_88x31_built.png
===================================================================
(Binary files differ)
Property changes on: trunk/examples/RestYUI/root/static/images/btn_88x31_built.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/examples/RestYUI/root/static/images/btn_88x31_built_shadow.png
===================================================================
(Binary files differ)
Property changes on: trunk/examples/RestYUI/root/static/images/btn_88x31_built_shadow.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/examples/RestYUI/root/static/images/btn_88x31_powered.png
===================================================================
(Binary files differ)
Property changes on: trunk/examples/RestYUI/root/static/images/btn_88x31_powered.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/examples/RestYUI/root/static/images/btn_88x31_powered_shadow.png
===================================================================
(Binary files differ)
Property changes on: trunk/examples/RestYUI/root/static/images/btn_88x31_powered_shadow.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/examples/RestYUI/root/static/images/catalyst_logo.png
===================================================================
(Binary files differ)
Property changes on: trunk/examples/RestYUI/root/static/images/catalyst_logo.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/examples/RestYUI/script/adventrest_cgi.pl
===================================================================
--- trunk/examples/RestYUI/script/adventrest_cgi.pl (rev 0)
+++ trunk/examples/RestYUI/script/adventrest_cgi.pl 2007-11-26 23:07:03 UTC (rev 7163)
@@ -0,0 +1,37 @@
+#!/usr/bin/perl -w
+
+BEGIN { $ENV{CATALYST_ENGINE} ||= 'CGI' }
+
+use strict;
+use warnings;
+use FindBin;
+use lib "$FindBin::Bin/../lib";
+use AdventREST;
+
+AdventREST->run;
+
+1;
+
+=head1 NAME
+
+adventrest_cgi.pl - Catalyst CGI
+
+=head1 SYNOPSIS
+
+See L<Catalyst::Manual>
+
+=head1 DESCRIPTION
+
+Run a Catalyst application as a cgi script.
+
+=head1 AUTHOR
+
+Sebastian Riedel, C<sri at oook.de>
+
+=head1 COPYRIGHT
+
+
+This library is free software, you can redistribute it and/or modify
+it under the same terms as Perl itself.
+
+=cut
Property changes on: trunk/examples/RestYUI/script/adventrest_cgi.pl
___________________________________________________________________
Name: svn:executable
+ *
Added: trunk/examples/RestYUI/script/adventrest_create.pl
===================================================================
--- trunk/examples/RestYUI/script/adventrest_create.pl (rev 0)
+++ trunk/examples/RestYUI/script/adventrest_create.pl 2007-11-26 23:07:03 UTC (rev 7163)
@@ -0,0 +1,74 @@
+#!/usr/bin/perl -w
+
+use strict;
+use warnings;
+use Getopt::Long;
+use Pod::Usage;
+use Catalyst::Helper;
+
+my $force = 0;
+my $mech = 0;
+my $help = 0;
+
+GetOptions(
+ 'nonew|force' => \$force,
+ 'mech|mechanize' => \$mech,
+ 'help|?' => \$help
+ );
+
+pod2usage(1) if ( $help || !$ARGV[0] );
+
+my $helper = Catalyst::Helper->new( { '.newfiles' => !$force, mech => $mech } );
+
+pod2usage(1) unless $helper->mk_component( 'AdventREST', @ARGV );
+
+1;
+
+=head1 NAME
+
+adventrest_create.pl - Create a new Catalyst Component
+
+=head1 SYNOPSIS
+
+adventrest_create.pl [options] model|view|controller name [helper] [options]
+
+ Options:
+ -force don't create a .new file where a file to be created exists
+ -mechanize use Test::WWW::Mechanize::Catalyst for tests if available
+ -help display this help and exits
+
+ Examples:
+ adventrest_create.pl controller My::Controller
+ adventrest_create.pl -mechanize controller My::Controller
+ adventrest_create.pl view My::View
+ adventrest_create.pl view MyView TT
+ adventrest_create.pl view TT TT
+ adventrest_create.pl model My::Model
+ adventrest_create.pl model SomeDB DBIC::Schema MyApp::Schema create=dynamic\
+ dbi:SQLite:/tmp/my.db
+ adventrest_create.pl model AnotherDB DBIC::Schema MyApp::Schema create=static\
+ dbi:Pg:dbname=foo root 4321
+
+ See also:
+ perldoc Catalyst::Manual
+ perldoc Catalyst::Manual::Intro
+
+=head1 DESCRIPTION
+
+Create a new Catalyst Component.
+
+Existing component files are not overwritten. If any of the component files
+to be created already exist the file will be written with a '.new' suffix.
+This behavior can be suppressed with the C<-force> option.
+
+=head1 AUTHOR
+
+Sebastian Riedel, C<sri at oook.de>
+Maintained by the Catalyst Core Team.
+
+=head1 COPYRIGHT
+
+This library is free software, you can redistribute it and/or modify
+it under the same terms as Perl itself.
+
+=cut
Property changes on: trunk/examples/RestYUI/script/adventrest_create.pl
___________________________________________________________________
Name: svn:executable
+ *
Added: trunk/examples/RestYUI/script/adventrest_fastcgi.pl
===================================================================
--- trunk/examples/RestYUI/script/adventrest_fastcgi.pl (rev 0)
+++ trunk/examples/RestYUI/script/adventrest_fastcgi.pl 2007-11-26 23:07:03 UTC (rev 7163)
@@ -0,0 +1,76 @@
+#!/usr/bin/perl -w
+
+BEGIN { $ENV{CATALYST_ENGINE} ||= 'FastCGI' }
+
+use strict;
+use warnings;
+use Getopt::Long;
+use Pod::Usage;
+use FindBin;
+use lib "$FindBin::Bin/../lib";
+use AdventREST;
+
+my $help = 0;
+my ( $listen, $nproc, $pidfile, $manager, $detach );
+
+GetOptions(
+ 'help|?' => \$help,
+ 'listen|l=s' => \$listen,
+ 'nproc|n=i' => \$nproc,
+ 'pidfile|p=s' => \$pidfile,
+ 'manager|M=s' => \$manager,
+ 'daemon|d' => \$detach,
+);
+
+pod2usage(1) if $help;
+
+AdventREST->run(
+ $listen,
+ { nproc => $nproc,
+ pidfile => $pidfile,
+ manager => $manager,
+ detach => $detach,
+ }
+);
+
+1;
+
+=head1 NAME
+
+adventrest_fastcgi.pl - Catalyst FastCGI
+
+=head1 SYNOPSIS
+
+adventrest_fastcgi.pl [options]
+
+ Options:
+ -? -help display this help and exits
+ -l -listen Socket path to listen on
+ (defaults to standard input)
+ can be HOST:PORT, :PORT or a
+ filesystem path
+ -n -nproc specify number of processes to keep
+ to serve requests (defaults to 1,
+ requires -listen)
+ -p -pidfile specify filename for pid file
+ (requires -listen)
+ -d -daemon daemonize (requires -listen)
+ -M -manager specify alternate process manager
+ (FCGI::ProcManager sub-class)
+ or empty string to disable
+
+=head1 DESCRIPTION
+
+Run a Catalyst application as fastcgi.
+
+=head1 AUTHOR
+
+Sebastian Riedel, C<sri at oook.de>
+Maintained by the Catalyst Core Team.
+
+=head1 COPYRIGHT
+
+This library is free software, you can redistribute it and/or modify
+it under the same terms as Perl itself.
+
+=cut
Property changes on: trunk/examples/RestYUI/script/adventrest_fastcgi.pl
___________________________________________________________________
Name: svn:executable
+ *
Added: trunk/examples/RestYUI/script/adventrest_server.pl
===================================================================
--- trunk/examples/RestYUI/script/adventrest_server.pl (rev 0)
+++ trunk/examples/RestYUI/script/adventrest_server.pl 2007-11-26 23:07:03 UTC (rev 7163)
@@ -0,0 +1,111 @@
+#!/usr/bin/perl -w
+
+BEGIN {
+ $ENV{CATALYST_ENGINE} ||= 'HTTP';
+ $ENV{CATALYST_SCRIPT_GEN} = 29;
+ require Catalyst::Engine::HTTP;
+}
+
+use strict;
+use warnings;
+use Getopt::Long;
+use Pod::Usage;
+use FindBin;
+use lib "$FindBin::Bin/../lib";
+
+my $debug = 0;
+my $fork = 0;
+my $help = 0;
+my $host = undef;
+my $port = 3000;
+my $keepalive = 0;
+my $restart = 0;
+my $restart_delay = 1;
+my $restart_regex = '\.yml$|\.yaml$|\.pm$';
+my $restart_directory = undef;
+
+my @argv = @ARGV;
+
+GetOptions(
+ 'debug|d' => \$debug,
+ 'fork' => \$fork,
+ 'help|?' => \$help,
+ 'host=s' => \$host,
+ 'port=s' => \$port,
+ 'keepalive|k' => \$keepalive,
+ 'restart|r' => \$restart,
+ 'restartdelay|rd=s' => \$restart_delay,
+ 'restartregex|rr=s' => \$restart_regex,
+ 'restartdirectory=s' => \$restart_directory,
+);
+
+pod2usage(1) if $help;
+
+if ( $restart ) {
+ $ENV{CATALYST_ENGINE} = 'HTTP::Restarter';
+}
+if ( $debug ) {
+ $ENV{CATALYST_DEBUG} = 1;
+}
+
+# This is require instead of use so that the above environment
+# variables can be set at runtime.
+require AdventREST;
+
+AdventREST->run( $port, $host, {
+ argv => \@argv,
+ 'fork' => $fork,
+ keepalive => $keepalive,
+ restart => $restart,
+ restart_delay => $restart_delay,
+ restart_regex => qr/$restart_regex/,
+ restart_directory => $restart_directory,
+} );
+
+1;
+
+=head1 NAME
+
+adventrest_server.pl - Catalyst Testserver
+
+=head1 SYNOPSIS
+
+adventrest_server.pl [options]
+
+ Options:
+ -d -debug force debug mode
+ -f -fork handle each request in a new process
+ (defaults to false)
+ -? -help display this help and exits
+ -host host (defaults to all)
+ -p -port port (defaults to 3000)
+ -k -keepalive enable keep-alive connections
+ -r -restart restart when files get modified
+ (defaults to false)
+ -rd -restartdelay delay between file checks
+ -rr -restartregex regex match files that trigger
+ a restart when modified
+ (defaults to '\.yml$|\.yaml$|\.pm$')
+ -restartdirectory the directory to search for
+ modified files
+ (defaults to '../')
+
+ See also:
+ perldoc Catalyst::Manual
+ perldoc Catalyst::Manual::Intro
+
+=head1 DESCRIPTION
+
+Run a Catalyst Testserver for this application.
+
+=head1 AUTHOR
+
+Sebastian Riedel, C<sri at oook.de>
+Maintained by the Catalyst Core Team.
+
+=head1 COPYRIGHT
+
+This library is free software, you can redistribute it and/or modify
+it under the same terms as Perl itself.
+
+=cut
Property changes on: trunk/examples/RestYUI/script/adventrest_server.pl
___________________________________________________________________
Name: svn:executable
+ *
Added: trunk/examples/RestYUI/script/adventrest_test.pl
===================================================================
--- trunk/examples/RestYUI/script/adventrest_test.pl (rev 0)
+++ trunk/examples/RestYUI/script/adventrest_test.pl 2007-11-26 23:07:03 UTC (rev 7163)
@@ -0,0 +1,54 @@
+#!/usr/bin/perl -w
+
+use strict;
+use warnings;
+use Getopt::Long;
+use Pod::Usage;
+use FindBin;
+use lib "$FindBin::Bin/../lib";
+use Catalyst::Test 'AdventREST';
+
+my $help = 0;
+
+GetOptions( 'help|?' => \$help );
+
+pod2usage(1) if ( $help || !$ARGV[0] );
+
+print request($ARGV[0])->content . "\n";
+
+1;
+
+=head1 NAME
+
+adventrest_test.pl - Catalyst Test
+
+=head1 SYNOPSIS
+
+adventrest_test.pl [options] uri
+
+ Options:
+ -help display this help and exits
+
+ Examples:
+ adventrest_test.pl http://localhost/some_action
+ adventrest_test.pl /some_action
+
+ See also:
+ perldoc Catalyst::Manual
+ perldoc Catalyst::Manual::Intro
+
+=head1 DESCRIPTION
+
+Run a Catalyst action from the command line.
+
+=head1 AUTHOR
+
+Sebastian Riedel, C<sri at oook.de>
+Maintained by the Catalyst Core Team.
+
+=head1 COPYRIGHT
+
+This library is free software, you can redistribute it and/or modify
+it under the same terms as Perl itself.
+
+=cut
Property changes on: trunk/examples/RestYUI/script/adventrest_test.pl
___________________________________________________________________
Name: svn:executable
+ *
Added: trunk/examples/RestYUI/t/01app.t
===================================================================
--- trunk/examples/RestYUI/t/01app.t (rev 0)
+++ trunk/examples/RestYUI/t/01app.t 2007-11-26 23:07:03 UTC (rev 7163)
@@ -0,0 +1,9 @@
+use strict;
+use warnings;
+use FindBin;
+use lib "$FindBin::Bin/../lib";
+use Test::More tests => 2;
+
+BEGIN { use_ok 'Catalyst::Test', 'AdventREST' }
+
+ok( request('/')->is_error, 'Request should fail' );
More information about the Catalyst-commits
mailing list