plack

how to pass arguments from an plack app to an mojolicious app enabled in builder?

徘徊边缘 提交于 2020-01-02 04:50:30
问题 given the example plack app using lots of middleware components and an mojolicious app enabled in builder (see below), how can i pass parameters from the app.psgi to Mojolicious without using the ugly %ENV hack shown? of cause passing an config is just an example, this could be any scalar/object. app.psgi use Plack::Builder; $ENV{CONFIG} = {...}; builder { ... Mojolicious::Commands->start_app('MyApp'); }; MyApp.pm package MyApp; use Mojo::Base 'Mojolicious'; sub startup { my $self = shift; my

How to set the expiration time for a cookie managed by Plack::Middleware::Session?

懵懂的女人 提交于 2020-01-02 02:41:26
问题 Now my app.psgi contains (simplified): builder { enable 'Session', store => 'File'; #default uses Plack::Session::State::Cookie $app; }; Later, in the $app I'm using: my $req = Plack::Request->new($env); my $session = $req->session(); #returns env->{'psgix.session'} $session->{user} = "name"; It works ok , e.g.: when the user logged in, I store his name in the server-side stored session-file, and the Plack::Middleware::Session sets an simple session-state-cookie, and when the user closing the

Handling multiple file uploads with Plack

偶尔善良 提交于 2019-12-30 17:43:28
问题 Trying handling multiple file uploads with Plack. My form: <form id="file_upload" action="savefile" method="POST" enctype="multipart/form-data"> <input type="file" name="file[]" multiple> <button>upload</button> </form> Selected two files, called: x1 and x2 . The Data::Dumper result of the: my $u = $req->uploads; is $VAR1 = bless( { 'file[]' => bless( { 'headers' => bless( { 'content-disposition' => 'form-data; name="file[]"; filename="x2"', 'content-type' => 'application/octet-stream', ':

An explanation of the nginx/starman/dancer web stack

别来无恙 提交于 2019-12-18 10:07:47
问题 I've been doing web-programming for a while now and am quite familiar with the LAMP stack. I've decided to try playing around with the nginx/starman/dancer stack and I'm a bit confused about how to understand, from a high-level, how all the pieces relate to each other. Setting up the stack doesn't seem as straight forward as setting up the LAMP stack, but that's probably because I don't really understand how the pieces relate. I understand the role nginx is playing - a lightweight webserver

An explanation of the nginx/starman/dancer web stack

蹲街弑〆低调 提交于 2019-12-18 10:07:08
问题 I've been doing web-programming for a while now and am quite familiar with the LAMP stack. I've decided to try playing around with the nginx/starman/dancer stack and I'm a bit confused about how to understand, from a high-level, how all the pieces relate to each other. Setting up the stack doesn't seem as straight forward as setting up the LAMP stack, but that's probably because I don't really understand how the pieces relate. I understand the role nginx is playing - a lightweight webserver

Accessing __DATA__ from super class

别来无恙 提交于 2019-12-10 19:03:17
问题 I have a super class called Response : package Response; use strict; use warnings; use HTML::Template; sub response { my ( $class, $request ) = @_; return $request->new_response( $class->status, $class->headers, $class->body ); } sub body { my $class = shift; my $template = HTML::Template->new( 'filehandle' => eval("$class::DATA") ); return $template->output() . $class; } sub status { return 200; } sub headers { return [ 'Content-Type' => 'text/html' ]; } 1; __DATA__ Default content and a

Best init script for running an application as a separate user

半腔热情 提交于 2019-12-09 13:29:26
问题 I have an application that runs in a user account (Plack-based) and want an init script. It seems as easy as "sudo $user start_server ...". I just wrote an LSB script using start-stop-daemon and it is really clumsy and verbose. It doesn't feel like the right way. After scouring for a bit and looking at a log of examples, I'm still not sure what the best way to do this is and there isn't a cohesive guide that I've found. Right now I have it working with: start-stop-daemon --background --quiet

Multilingual PSGI-web deployment

天涯浪子 提交于 2019-12-09 11:17:32
问题 I plan develop one web application with PSGI/Plack. (probaly with Dancer, but not decided yet). The applicatiion should be utf8, multilingual (with Locale::Maketext) and (ofc) will contain some statical pages in the given language. My idea is deploy it in different language domains like en.example.com , de.example.com etc. The application itself is simple, mostly will only fill templates with localized texts and some other (light) functionality. What is the best solution to deploying one

plackup access log - locale and open pragma - encoding problem

南笙酒味 提交于 2019-12-08 00:40:46
问题 My locale setting is utf8, so, when starting plackup the date strings are localized too. Therefore I getting console access-log like the following: $ plackup a.psgi HTTP::Server::PSGI: Accepting connections at http://0:5000/ 127.0.0.1 - - [24/júl/2011:12:15:44 +0200] "GET / HTTP/1.1" 200 11 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7) AppleWebKit/534.48.3 (KHTML, like Gecko) Version/5.1 Safari/534.48.3" ^- garbage my partial a.psgi: use 5.014; use warnings; use utf8; use open qw(:std

plackup access log - locale and open pragma - encoding problem

旧时模样 提交于 2019-12-06 07:44:38
My locale setting is utf8, so, when starting plackup the date strings are localized too. Therefore I getting console access-log like the following: $ plackup a.psgi HTTP::Server::PSGI: Accepting connections at http://0:5000/ 127.0.0.1 - - [24/júl/2011:12:15:44 +0200] "GET / HTTP/1.1" 200 11 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7) AppleWebKit/534.48.3 (KHTML, like Gecko) Version/5.1 Safari/534.48.3" ^- garbage my partial a.psgi: use 5.014; use warnings; use utf8; use open qw(:std :utf8); #the problem.... use Encode; use Plack::Builder; use MyApp; my $runner = MyApp->new(...); my $app