/[Frey]/trunk/lib/Frey/REST.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Annotation of /trunk/lib/Frey/REST.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 26 - (hide annotations)
Sun Jun 29 18:08:50 2008 UTC (15 years, 10 months ago) by dpavlin
File size: 784 byte(s)
another refacture and version bump [0.02]
- added support for error pages
- added list of classes
1 dpavlin 19 package Frey::REST;
2    
3     use strict;
4     use warnings;
5    
6     use Template::Declare::Tags; # defaults to 'HTML'
7     use base 'Template::Declare';
8    
9     use Data::Dump qw/dump/;
10 dpavlin 26
11 dpavlin 23 use Frey::HTML;
12 dpavlin 26 use Strix::User;
13 dpavlin 19
14     =head1 NAME
15    
16     Frey::REST - dispatch REST like URLs into method calls
17    
18     =cut
19    
20     =head1 METHODS
21    
22     =head2 user
23    
24     =cut
25    
26     template 'user' => sub {
27     my ( $self, $req ) = @_;
28    
29 dpavlin 26 warn "req ref = ",ref($req);
30 dpavlin 19
31 dpavlin 26 die "req: ",ref($req) if ref($req) ne 'Continuity::RequestHolder';
32 dpavlin 19
33 dpavlin 26 my $id = $req->param('id') if $req->can('param');
34    
35     my $user = eval { Strix::User->new( id => $id ); };
36     warn "## user $id: $@";
37    
38 dpavlin 19 if ( ! $user ) {
39 dpavlin 23 $req->conn->send_status_line( 404, "user $id" );
40 dpavlin 26 $req->print( "Can't find user with id $id\n$@" );
41 dpavlin 19 } else {
42 dpavlin 23 $req->print( Frey::HTML->page( 'show-user', $req, $user ) );
43     };
44 dpavlin 19 };
45    

  ViewVC Help
Powered by ViewVC 1.1.26