Created
December 10, 2013 16:08
-
-
Save wesyoung/7893163 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env perl | |
| use 5.011; | |
| use strict; | |
| use warnings; | |
| use AnyEvent; | |
| use Data::Dumper; | |
| use ZMQx::Class; | |
| use Plack::Runner qw(); | |
| use JSON::XS; | |
| use constant ZMQ_ROUTER_CONNECT => 'tcp://localhost:5555'; | |
| my $r = ZMQx::Class->socket('REQ', connect => ZMQ_ROUTER_CONNECT()); | |
| my $ret; | |
| my $app = sub { | |
| my $env = shift; | |
| my $path = $env->{'PATH_INFO'}; | |
| $ret = $r->send("request $path"); | |
| say $ret; | |
| $ret = $r->receive('blocking'); | |
| say @$ret[0]; | |
| $ret = JSON::XS::encode_json($ret); | |
| return [ | |
| '200', | |
| ['Content-Type' => 'application/json'], | |
| [$ret], | |
| ]; | |
| }; | |
| my $runner = Plack::Runner->new(); | |
| $runner->parse_options(@ARGV); | |
| $runner->run($app); |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
$ lwp-request http://localhost:5000/test