Updated script generation
[catagits/Catalyst-Runtime.git] / lib / Catalyst / Utils.pm
index c76a247..c0eeefe 100644 (file)
@@ -24,7 +24,9 @@ See L<Catalyst>.
 
 =item appprefix($class)
 
-Returns the application prefix for the class
+Returns the application prefix for the class.
+
+       MyApp::Foo becomes myapp_foo
 
 =cut
 
@@ -224,6 +226,28 @@ sub reflect_actions {
     return $actions;
 }
 
+=item request($request)
+
+Returns a HTTP::Request object.
+
+=cut
+
+sub request {
+    my $request = shift;
+    unless ( ref $request ) {
+        if ( $request =~ m/http/i ) {
+            $request = URI->new($request)->canonical;
+        }
+        else {
+            $request = URI->new( 'http://localhost' . $request )->canonical;
+        }
+    }
+    unless ( ref $request eq 'HTTP::Request' ) {
+        $request = HTTP::Request->new( 'GET', $request );
+    }
+    return $request;
+}
+
 =back
 
 =head1 AUTHOR