Skip to content

Commit

Permalink
Dispatcher and router approach at slow speed
Browse files Browse the repository at this point in the history
  • Loading branch information
ash committed Oct 11, 2011
1 parent 204cb25 commit 47dcaaa
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 3 deletions.
2 changes: 1 addition & 1 deletion areno.psgi
Expand Up @@ -7,7 +7,7 @@ sub {
my ($env) = @_;

my $areno = new Areno();
$areno->run();
$areno->run($env);

return [$areno->status(), $areno->headers(), $areno->body()];
}
27 changes: 25 additions & 2 deletions lib/Areno.pm
Expand Up @@ -2,6 +2,9 @@ package Areno;

use strict;

use Cwd;
use Areno::Dispatch;

sub new {
my ($class) = @_;

Expand All @@ -12,13 +15,31 @@ sub new {
'Content-Type' => 'text/html',
],
body => ['I am Areno.'],
}
},
dispatch => new Areno::Dispatch(),
};
bless $this, $class;

$this->init();

return $this;
}

sub init {
my ($this) = @_;

my $base_path = getcwd() || '.';
my $sites_path = "$base_path/sites";

opendir my($sites), $sites_path;
die "No 'sites' directory found at $base_path" unless $sites;
my @sites = grep /\w/, grep {-d "$sites_path/$_"} readdir $sites;
close $sites;
die "No sites found in $sites_path" unless @sites;

warn Dumper(\@sites); use Data::Dumper;
}

sub status {
my ($this) = @_;

Expand All @@ -38,8 +59,10 @@ sub body {
}

sub run {
my ($this) = @_;
my ($this, $env) = @_;

#my $page = $this->{dispatch}->dispatch($env);
#$page->run();
}

1;
24 changes: 24 additions & 0 deletions lib/Areno/Dispatch.pm
@@ -0,0 +1,24 @@
package Areno::Dispatch;

use strict;

sub new {
my ($class) = @_;

my $this = {
};
bless $this, $class;

return $this;
}

sub dispatch {
my ($this, $env) = @_;

my $server_name = $env->{SERVER_NAME} || 'default';
my $request_uri = $env->{REQUEST_URI} || '/';


}

1;

0 comments on commit 47dcaaa

Please sign in to comment.