Changeset 10394 for lang/perl/HTTPx-Dispatcher/trunk
- Timestamp:
- 04/25/08 10:18:14 (5 years ago)
- Location:
- lang/perl/HTTPx-Dispatcher/trunk
- Files:
-
- 2 modified
-
lib/HTTPx/Dispatcher/Rule.pm (modified) (2 diffs)
-
t/01_simple.t (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
lang/perl/HTTPx-Dispatcher/trunk/lib/HTTPx/Dispatcher/Rule.pm
r10390 r10394 74 74 my ($self, $req) = @_; 75 75 76 $self->condition_check_method($req) ;76 $self->condition_check_method($req) && $self->condition_check_function($req); 77 77 } 78 78 79 79 sub condition_check_method { 80 80 my ($self, $req) = @_; 81 croak "request required" unless blessed $req; 81 82 82 83 my $method = $self->conditions->{method}; … … 92 93 } 93 94 95 sub condition_check_function { 96 my ($self, $req) = @_; 97 croak "request required" unless blessed $req; 98 99 my $function = $self->conditions->{function}; 100 return 1 unless $function; 101 102 local $_ = $req; 103 if ( $function->( $req ) ) { 104 return 1; 105 } else { 106 return 0; 107 } 108 } 109 94 110 1; 95 111 -
lang/perl/HTTPx-Dispatcher/trunk/t/01_simple.t
r10390 r10394 153 153 controller: user 154 154 155 === function condition(1) 156 --- input 157 src: |+ 158 connect 'edit' => { 159 conditions => { 160 function => sub { $_->method =~ /get/i }, 161 }, 162 controller => 'user', 163 action => 'get_root', 164 }; 165 connect 'edit' => { 166 conditions => { 167 function => sub { $_->method =~ /post/i }, 168 }, 169 controller => 'user', 170 action => 'post_root', 171 }; 172 uri: /edit 173 method: POST 174 --- expected 175 action: post_root 176 controller: user 177 178 === function condition(2) 179 --- input 180 src: |+ 181 connect 'edit' => { 182 conditions => { 183 function => sub { $_->method =~ /get/i }, 184 }, 185 controller => 'user', 186 action => 'get_root', 187 }; 188 connect 'edit' => { 189 conditions => { 190 function => sub { $_->method =~ /post/i }, 191 }, 192 controller => 'user', 193 action => 'post_root', 194 }; 195 uri: /edit 196 method: GET 197 --- expected 198 action: get_root 199 controller: user 200
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)