summary refs log tree commit diff
diff options
context:
space:
mode:
authorfranck cuny <franck@lumberjaph.net>2010-06-08 09:58:13 +0200
committerfranck cuny <franck@lumberjaph.net>2010-06-08 09:58:13 +0200
commita911db65ddc6e9a7f480ba9a45653bf4ad419b6b (patch)
treece1dc2632993e075caecf12d7b3f6983a2c9eaa9
parentrewrite meta API: use _net_api_ in name, add find_net_api_method_by_name (diff)
downloadmoosex-net-api-a911db65ddc6e9a7f480ba9a45653bf4ad419b6b.tar.gz
remove http-console
-rw-r--r--bin/http-console90
1 files changed, 0 insertions, 90 deletions
diff --git a/bin/http-console b/bin/http-console
deleted file mode 100644
index 3871c36..0000000
--- a/bin/http-console
+++ /dev/null
@@ -1,90 +0,0 @@
-use strict;
-use warnings;
-use 5.010;
-
-use Term::ReadLine;
-use Getopt::Long;
-use JSON;
-
-my $url         = shift;
-my $format_mode = 'append';
-my $format      = 'json';
-
-GetOptions(
-    'm=s' => \$format_mode,
-    'f=s' => \$format,
-);
-
-package http::net::console;
-use MooseX::Net::API;
-
-package main;
-
-my ($content, $result);
-
-my $term   = Term::ReadLine->new("http::net::console");
-my $prompt = $url . '> ';
-while (defined(my $in = $term->readline($prompt))) {
-    map { http::net::console->meta->remove_net_api_method($_) }
-      http::net::console->meta->get_all_api_methods();
-    if ($in =~ /^(GET|DELETE)\s(.*)$/) {
-        my $http_console = http::net::console->new(
-            api_base_url    => $url,
-            api_format      => $format,
-            api_format_mode => $format_mode
-        );
-        $http_console->meta->add_net_api_method(
-            'anonymous',
-            method => $1,
-            path   => $2
-        );
-        ($content, $result) = $http_console->anonymous;
-        say JSON->new->pretty->encode($content);
-    }
-    elsif ($in =~ /^(POST|PUT)\s(.*)(?:\s(.*))$/) {
-        my $method       = $1;
-        my $path         = $2;
-        my $data         = $3;
-        my $http_console = http::net::console->new(
-            api_base_url    => $url,
-            api_format      => $format,
-            api_format_mode => $format_mode,
-        );
-        $http_console->meta->add_net_api_method(
-            'anonymous',
-            method => $method,
-            path   => $path
-        );
-        $http_console->api_useragent->add_handler(
-            request_prepare => sub {
-                my $request = shift;
-                $request->content($data);
-            }
-        );
-        ($content, $result) = $http_console->anonymous;
-        say pretty_output($content);
-    }
-    elsif ($in eq 'show headers') {
-        if (defined $result) {
-            map { say $_ . ": " . $result->header($_) }
-              keys %{$result->headers};
-            say "";
-        }
-        else {
-            say "no headers to show";
-        }
-
-    }
-    elsif ($in eq 'show content') {
-        if (defined $content) {
-            say pretty_output($content);
-        }
-        else {
-            say "no content to show";
-        }
-    }
-}
-
-sub pretty_output {
-    JSON->new->pretty->encode(shift);
-}