Giter Club home page Giter Club logo

perl5-anyevent-plackup's Introduction

NAME

AnyEvent::Plackup - Easily establish an HTTP server inside a program

SYNOPSIS

use AnyEvent::Plackup;

my $server = plackup(); # port is automatically chosen
my $req = $server->recv; # isa Plack::Request

my $value = $req->parameters->{foo};

$req->respond([ 200, [], [ 'OK' ] ]);

# or specify PSGI app:

my $server = plackup(app => \&app);

DESCRIPTION

AnyEvent::Plackup provides functionality of establishing an HTTP server inside a program using Twiggy. If not specified, open port is automatically chosen.

FUNCTIONS

  • my $server = AnyEvent::Plackup->new([ app => \&app, port => $port, %args ])

  • my $server = plackup([ app => \&app, port => $port, %args ])

    Creates and starts an HTTP server. Internally calls new and run.

    If app is not specified, $server->recv is available and you should respond this manually.

  • my $req = $server->recv

    Waits until next request comes. Returns an AnyEvent::Plackup::Request (isa Plack::Request).

  • my $origin = $server->origin

  • my $origin = "$server"

    Returns server's origin. e.g. "http://0.0.0.0:8290".

  • $server->shutdown

    Shuts down the server immediately.

AUTHOR

motemen [email protected]

SEE ALSO

Twiggy

LICENSE

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

perl5-anyevent-plackup's People

Contributors

motemen avatar

Stargazers

Olivier Mengué avatar

Watchers

 avatar James Cloos avatar  avatar

perl5-anyevent-plackup's Issues

t/01_plackup.t fails with recent Test::More

Test output:

#   Failed test 'planned to run 4 but done_testing() expects 0'
#   at t/01_plackup.t line 22.

#   Failed test 'planned to run 4 but done_testing() expects 5'
#   at t/01_plackup.t line 22.
# Looks like you planned 4 tests but ran 6.
# Looks like you failed 2 tests of 6 run.
t/01_plackup.t .. 
Dubious, test returned 2 (wstat 512, 0x200)
All 4 subtests passed 

Statistical analysis suggests that the problem happens only with recent Test::More versions:

****************************************************************
Regression 'mod:Test::More'
****************************************************************
Name                   Theta          StdErr     T-stat
[0='const']           1.0000          0.0000    27513430273965384.00
[1='eq_1.001006']             0.0000          0.0000       0.00
[2='eq_1.001014']            -0.0000          0.0000      -4.07
[3='eq_1.302015']            -1.0000          0.0000    -21865457191032056.00
[4='eq_1.302019']            -1.0000          0.0000    -22464621748286116.00

R^2= 1.000, N= 63, K= 5
****************************************************************

@exodist: FYI

t/01_plackup.t hangs on Windows

C:\strawberry180\cpan\build\AnyEvent-Plackup-0.01-cmrdbB>perl -Mblib t/01_plackup.t
1..4
not ok 1
#   Failed test at t/01_plackup.t line 18.
#          got: '500'
#     expected: '200'
not ok 2
#   Failed test at t/01_plackup.t line 19.
#          got: 'Can't connect to 0.0.0.0:50946 (10049)
#
# LWP::Protocol::http::Socket: connect: 10049 at C:/strawberry180/perl/vendor/lib/LWP/Protocol/http.pm line 51.
# '
#     expected: 'AnyEvent::Plackup'
not ok 3 - planned to run 4 but done_testing() expects 2
#   Failed test 'planned to run 4 but done_testing() expects 2'
#   at C:/strawberry180/perl/lib/Test/More.pm line 221.
(hangs)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.