6 |
|
|
7 |
use Data::Dump qw/dump/; |
use Data::Dump qw/dump/; |
8 |
|
|
9 |
|
#use Carp::REPL; # 'nodie'; |
10 |
|
|
11 |
use lib 'lib'; |
use lib 'lib'; |
12 |
use Frey::Run; |
use Frey::Run; |
13 |
|
|
55 |
} |
} |
56 |
|
|
57 |
my $path = $url->path; |
my $path = $url->path; |
58 |
my $content_type = 'text/plain'; |
|
59 |
|
if ( $path =~ m{^/(favicon.ico|__history__.html)$} ) { |
60 |
|
warn "INFO: $path ignored"; |
61 |
|
return { code => 404, content_type => 'text/plain' }; |
62 |
|
} |
63 |
|
|
64 |
|
my $request = { |
65 |
|
content_type => 'text/html', |
66 |
|
code => 200, |
67 |
|
}; |
68 |
|
|
69 |
eval { |
eval { |
|
# { |
|
70 |
|
|
71 |
if ( $path =~ m{/reload(.*)} ) { |
if ( $path =~ m{/reload(.*)} ) { |
72 |
|
|
122 |
$self->print( $self->editor->command( $path ) ); |
$self->print( $self->editor->command( $path ) ); |
123 |
return; |
return; |
124 |
} elsif ( |
} elsif ( |
125 |
$path =~ m{/([^/]+)/(\w*as_\w+)/?([^/]+)?} |
$path =~ m{/([^/]+)/(\w+)/?([^/]+)?} |
126 |
) { |
) { |
127 |
my $class = rest2class $1; |
my $class = rest2class $1; |
128 |
warn "# run $path -> $class $2"; |
warn "# run $path -> $class $2"; |
137 |
$run->{class} ||= $class; |
$run->{class} ||= $class; |
138 |
$f = Frey::Run->new( class => 'Frey::Introspect', params => $run ); |
$f = Frey::Run->new( class => 'Frey::Introspect', params => $run ); |
139 |
} else { |
} else { |
140 |
$f = Frey::Run->new( class => 'Frey::ClassBrowser', params => $run ); |
$f = Frey::Run->new( class => 'Frey::Class::Browser', params => $run ); |
141 |
} |
} |
142 |
|
|
143 |
if ( $f ) { |
if ( $f ) { |
154 |
confess "# can't call request on nothing!"; |
confess "# can't call request on nothing!"; |
155 |
} |
} |
156 |
|
|
157 |
$content_type = $f->content_type; |
$request->{content_type} = $f->content_type; |
158 |
}; |
}; |
159 |
|
|
160 |
if ( $@ ) { |
if ( $@ ) { |
161 |
warn "SERVER ERROR: $@"; |
warn "SERVER ERROR: $@"; |
162 |
# $req->conn->send_error( 404 ); # FIXME this should probably be 500, but we can't ship page with it |
$self->print( qq|<pre class="frey-error">$@<pre>| ); |
|
$self->print( qq{<pre class="frey-error">$@<pre>\r\n\r\n} ); |
|
163 |
# Carp::REPL::repl; |
# Carp::REPL::repl; |
164 |
|
return { |
165 |
|
content_type => 'text/html', |
166 |
|
code => 404, |
167 |
|
} |
168 |
} |
} |
169 |
|
|
170 |
return $content_type; |
return $request; |
171 |
} |
} |
172 |
|
|
173 |
sub refresh { |
sub refresh { |