PSGI ou Perl Web Server Gateway Interface est écrit par Tatsuhiko Miyagawa. C'est une interface entre un serveur web et une application web écrite en Perl. Il permet d’écrire des applications portables, avec possibilité de tourner avec mod_perl, CGI, FastCGI. C’est l’équivalent de Web Server Gateway Interface1 pour Python, ou de Rack pour Ruby.
Une application PSGI Perl est une sous-routine qui accepte en argument une référence d'un hash, et retourne un arrayref de trois éléments : un statut http, un arrayref contenant les headers http et un arrayref contenant le corps.
Plack est une implémentation de référence de PSGI.
Frameworks supportant PSGI Les frameworks web supportant PSGI :
Catalyst
Continuity Dancer HTTP::Engine Mason Maypole Mojolicious Piglet Squatting Starman Tatsumaki
Exemple
Un exemple d'application PSGI.
my $app = sub { return [200, ['Content-Type' => 'text/plain'], ["hello, world\n"]]; } Sauvez le fichier sous le nom "app.psgi", lancez "plackup"
Sources et références
Hébergement Web avec le support de la norme PSGI dotcloud.com niwacap.com
Liens externes Plack and PSGI, various links to servers and frameworks PSGI - Perl Web Server Gateway Interface Specification article on Plack and nginx from Catalyzed.org Plack Advent calendar Plack coverage, Catalyst Advent calendar
Catégorie:Perl