<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Sukria.net &#187; CGI</title>
	<atom:link href="http://www.sukria.net/fr/archives/tag/cgi/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.sukria.net/fr</link>
	<description>I will press many keys on my keyboard causing an implementation to occur.</description>
	<lastBuildDate>Wed, 18 Jan 2012 17:11:38 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Using Plack to run a Dancer app under a CGI environment</title>
		<link>http://www.sukria.net/fr/archives/2010/01/11/using-plack-to-run-a-dancer-app-under-a-cgi-environment/</link>
		<comments>http://www.sukria.net/fr/archives/2010/01/11/using-plack-to-run-a-dancer-app-under-a-cgi-environment/#comments</comments>
		<pubDate>Mon, 11 Jan 2010 17:43:04 +0000</pubDate>
		<dc:creator>sukria</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[CGI]]></category>
		<category><![CDATA[Dancer]]></category>
		<category><![CDATA[Plack]]></category>

		<guid isPermaLink="false">http://www.sukria.net/fr/?p=1373</guid>
		<description><![CDATA[Sawyer X on blogs.perl.org recently wondered how one could run a Dancer application under a 100% CGI environment. Indeed, he came up quickly with a REST app in development stage and wanted to go on air with a plain old CGI script. He seems to think it&#8217;s not possible with Dancer but as Dancer supports &#8230; <a href="http://www.sukria.net/fr/archives/2010/01/11/using-plack-to-run-a-dancer-app-under-a-cgi-environment/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Sawyer X on blogs.perl.org recently <a href="http://blogs.perl.org/users/sawyer_x/2010/01/i-gotz-me-a-dancer.html">wondered</a> how one could run a Dancer application under a 100% CGI environment. </p>
<p>Indeed, he came up quickly with a REST app in development stage and wanted to go on air with a plain old CGI script. He seems to think it&#8217;s not possible with Dancer but as Dancer supports PSGI/Plack, he&#8217;s wrong ;)</p>
<p>Thanks to the PSGI/Plack goodness, any application can be powered by a Plack-supported server. CGI is one of them and is implemented by <a href="http://search.cpan.org/~miyagawa/Plack-0.9030/lib/Plack/Server/CGI.pm">Plack::Server::CGI</a>. </p>
<p>By taking a quick look at the POD, we see that all we have to do is to write a pretty simple CGI script to bridge the Dancer app with Apache:</p>
<pre class="prettyprint">
#!/usr/bin/perl

use Plack::Server::CGI;
use Plack::Util;

my $psgi = '/path/to/your/app/app.psgi';
my $app = Plack::Util::load_psgi($psgi);
Plack::Server::CGI->new->run($app);
</pre>
<p>We now have to tell Apache that everything should be dispatched to that very CGI script like the following:</p>
<pre class="prettyprint">
&lt;VirtualHost ....&gt;
	&lt;Directory "/path/to/your/app"&gt;
		AllowOverride None
		Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
		Order allow,deny
		Allow from all
		AddHandler cgi-script .cgi
	&lt;/Directory&gt;

	RewriteCond %{REQUEST_FILENAME} !-f
	RewriteRule ^(.*)$ /dancer.cgi [QSA,L]

        [...]
&lt;/VirtualHost&gt;
</pre>
<p>And&#8230; we&#8217;re done! Every request the Apache server catches is now served by Dancer through Plack::Server::CGI</p>
<p>All I have to say here is &#8230; <a href="http://plackperl.org">Plack</a>++ (or <a href="http://twitter.com/miyagawa">@miyagawa</a>++ which seems to be the same ;-)</p>
<div id='teoShare' ><div id='teo2Google'>
		<!-- Place this tag where you want the +1 button to render -->
		<g:plusone size='tall' annotation='none'></g:plusone>

		<!-- Place this render call where appropriate -->
		<script type='text/javascript'>
		  (function() {
			var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
			po.src = 'https://apis.google.com/js/plusone.js';
			var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
		  })();
		</script>
		</div><div id="teoTweet" >
		<a href="http://twitter.com/share" class="twitter-share-button" data-count="none" data-via="sukria">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script> </div></div><div style="height:0px; width:0px; overflow:hidden;"><a href="http://www.zeitblog.com/?in=plugin">blog tools and plugins from www.zeitblog.com</a></div><p>Related posts:<ol>
<li><a href='http://www.sukria.net/fr/archives/2009/09/20/mounting-a-dancer-app-into-apache-psgiplack/' rel='bookmark' title='Mounting a Dancer app into Apache + PSGI/Plack'>Mounting a Dancer app into Apache + PSGI/Plack</a> <small>EDIT : This is going to change as soon as...</small></li>
<li><a href='http://www.sukria.net/fr/archives/2009/09/19/perl-dancer-0-9904-released/' rel='bookmark' title='Perl Dancer 0.9904 released'>Perl Dancer 0.9904 released</a> <small>I&#8217;ve just published a new version of Dancer. It&#8217;s basically...</small></li>
<li><a href='http://www.sukria.net/fr/archives/2010/07/03/perl-dancer-meeting-1-report/' rel='bookmark' title='Perl Dancer meeting #1 report'>Perl Dancer meeting #1 report</a> <small>Here is my quick report of the first Dancer meeting...</small></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.sukria.net/fr/archives/2010/01/11/using-plack-to-run-a-dancer-app-under-a-cgi-environment/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
	</channel>
</rss>

