Advertisement
Guest User

Untitled

a guest
Apr 9th, 2016
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 6 0.62 KB | None | 0 0
  1. class Abc {
  2.     has Str $.method;
  3.     has Regex $.path is required;
  4.  
  5.     method match (Str $method, Str $path) {
  6.         return False if $.method ne $method;
  7.         return $path ~~ $.path;
  8.     }
  9. }
  10.  
  11. my @routes = (
  12.     Abc.new(method => "GET", path => / ^ '/'foo $ / );
  13.     Abc.new(method => "POST", path => / ^ '/'bar $ /);
  14. );
  15.  
  16. sub foo($meth, $uri) {
  17.     for @routes -> $r {
  18.         if my $match = $r.match($meth, $uri) { die "What?!" unless $match }
  19.     }
  20. }
  21.  
  22. my @hex = ('A'..'F', 'a'..'f', 0..9).flat;
  23. for @hex -> $first {
  24.     for @hex -> $second {
  25.         foo("POST", 'http://127.0.0.1/utf8');
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement