Questions tagged [plack]

Plack is a Perl module and toolkit that contains middleware, helpers and adapters to web servers. PSGI is an interface between Perl web applications and web servers.

Plack is a set of tools that contains middleware components, a reference server and utilities for Web application frameworks using the stack.

A little Plack Handbook is available to get started with Plack and PSGI. Also see the Plack Advent Calenda with 24 useful short posts explaining the concept of PSGI and tutorials.

Web site: http://plackperl.org/

102 questions
4
votes
0 answers

Perl's PSGI/Plack and streaming response content

I'm exploring PSGI/Plack and how to do streaming/delayed responses. Already google'd around but find little to no examples of how to do it. Below are little bits and pieces I gathered from the PSGI::FAQ on metacpan. For example, if I want to stream…
santa100
  • 255
  • 1
  • 5
4
votes
1 answer

Set custom environment variable to psgi hash plack

When I do a request to dumper $env I get all data of enviromment hash psgi, in this example sub { my $env = shift; return [ 200, [], [ $env->{REMOTE_ADDR} ] ]; } or more directly sub { return [ 200, [], [ shift->{REMOTE_ADDR} ] ]; …
Imylor
  • 384
  • 1
  • 9
4
votes
1 answer

Run perl Plackup script from Scheduled Task

How can I call a script with that preceding argument before the script path using Task Scheduler or a batch file? plackup E:\Mojolicious_server.pl So I have multiple Mojolicious applications. I have bundled them all into a psgi server using…
gregnnylf94
  • 370
  • 3
  • 16
4
votes
2 answers

How can I use coderefs instead literal subs when there is a `&` prototype?

I'm trying to make Router::Resource work where the parameters to the functions are not literal anonymous subs, but coderefs defined earlier. I am doing this to curtail code duplication. Here's the code from the synopsis in a minimal but working…
daxim
  • 39,270
  • 4
  • 65
  • 132
4
votes
1 answer

Mount "hosts" in Plack::Builder

The Synopsis for the Plack::Builder and also this answer says: # in .psgi use Plack::Builder; my $app = sub { ... }; builder { mount "/foo" => builder { enable "Foo"; $app; }; mount "/bar" => $app2; mount…
cajwine
  • 3,100
  • 1
  • 20
  • 41
4
votes
1 answer

How do I avoid 502 responses with Plack and Mojolicious?

I have set up a small Mojolicious app to run behind Plack acting as proxy like this: builder { mount "/q" => builder { Plack::App::Proxy->new(remote => "http://127.0.0.1:3010")->to_app; }; }; I need to run it this way (rather…
simone
  • 4,667
  • 4
  • 25
  • 47
4
votes
2 answers

How do you use Plack::Middleware::Session with a Twiggy server?

I have a Twiggy based perl server: my $app = sub { my $req = Plack::Request->new(shift); ... }; my $twiggy = Twiggy::Server->new(port => $port); $twiggy->register_service($app); It works fine, but now I want to add session management to it (to…
sbs
  • 1,139
  • 3
  • 13
  • 19
4
votes
1 answer

How do I run Plack::Runner in the background?

I am trying to run a server with Plack::Runner. How do I run it in the background? I've tried the following: my $runner = Plack::Runner->new; $runner->parse_options(qw' --host 127.0.0.1 --port 90210 -D'); $runner->run($app); It seems to ignore the…
user_78361084
  • 3,538
  • 22
  • 85
  • 147
4
votes
1 answer

ZMQ sockets block when Starman receives HUP

I have the following code. I want to call the $pub->close method when the starman server receives the HUP signal. How do I know that the child process ends? Could I use an END {} block? I tried this and it seems to work when plackup restarts…
Peter Stuifzand
  • 5,084
  • 1
  • 23
  • 28
4
votes
1 answer

Using PSGI, is it possible to change how uploaded files are named?

I have a small PSGI app which takes an upload from a form and passes it off to another script for processing: #!/usr/bin/perl use strict; use warnings; use Plack::Request; use HTTPStatusCode; my $app = sub { my $req =…
RobEarl
  • 7,862
  • 6
  • 35
  • 50
3
votes
1 answer

How to turn a static CGI-style perl script(xxx.pl) to a dynamic PSGI application?

CGI-style perl scripts are hard to test in this style: def test_it_says_hello_to_a_person get '/home.pl', :name => 'Simon' assert last_response.body.include?('Simon') end (Note: the code is in ruby, using Rack::Test). But if I can turn static…
winteen
  • 45
  • 6
3
votes
2 answers

Perl-Starman (PSGI) + PHP = Apache2 proxy setup? - How to do?

How to run together: PSGI and PHP? I have Perl/PSGI application (running under pure perl Starman server). Now, for some reason need run one PHP application too ;(, so (probably) need Apache2. Questions: really need Apache for PHP? or exists some…
clt60
  • 62,119
  • 17
  • 107
  • 194
3
votes
3 answers

How do you deploy a PSGI script in Apache without restarting?

I want to deploy a PSGI scripts that runs in Apache2 with Plack. Apache is configured with: SetHandler perl-script PerlResponseHandler Plack::Handler::Apache2 PerlSetVar psgi_app /path/to/my/script.psgi When…
Jakob
  • 3,570
  • 3
  • 36
  • 49
3
votes
2 answers

How to can one Plack application affect another one?

I have this: use Plack::Builder; my $config_app = sub {...}; my $app = sub {...} builder { mount "/admin" => $config_app; mount "/" => $app; }; the $config_app saving configuration values into file app.cfg and the $app loading it as…
kobame
  • 5,766
  • 3
  • 31
  • 62
3
votes
3 answers

PSGI Response: What kinds of filehandles can be expected to work with PSGI, and Plack?

The PSGI specification defines the HTTP response as consisting of three parts, the third of which may be either an array reference or a filehandle. The filehandle may be: An IO::Handle-like object or a built-in filehandle. And the spec goes on to…
Lumi
  • 14,775
  • 8
  • 59
  • 92