Skip to content

Commit

Permalink
newlines
Browse files Browse the repository at this point in the history
  • Loading branch information
miyagawa committed Sep 11, 2012
1 parent 7af18f0 commit 706c2f5
Show file tree
Hide file tree
Showing 19 changed files with 15 additions and 22 deletions.
2 changes: 1 addition & 1 deletion 02_hello_world.md
Expand Up @@ -50,4 +50,4 @@ Want to display something not text by reading a file? Do this.
}
};

This app would serve favicon.ico if the request path looks like /favicon.ico, the "Hello World" page with requests to the root (/) and otherwise 404. You can see that a perl filehandle ($fh) is a valid PSGI response, and you can use whatever valid HTTP status code to return something different.
This app would serve favicon.ico if the request path looks like /favicon.ico, the "Hello World" page with requests to the root (/) and otherwise 404. You can see that a perl filehandle ($fh) is a valid PSGI response, and you can use whatever valid HTTP status code to return something different.
2 changes: 1 addition & 1 deletion 03_using_plackup.md
Expand Up @@ -33,4 +33,4 @@ or specify the unix domain socket the FCGI backend would listen:

> plackup -s FCGI --listen /tmp/fcgi.sock app.psgi

For more options for plackup, run perldoc plackup from the command line. You'll see more plackup options and hacks tomorrow as well.
For more options for plackup, run perldoc plackup from the command line. You'll see more plackup options and hacks tomorrow as well.
2 changes: 1 addition & 1 deletion 04_reloading_applications.md
Expand Up @@ -38,4 +38,4 @@ For instance, if your application uses Moose and DBIx::Class, then you can say:

> plackup -MMoose -MDBIx::Class -L Shotgun myapp.psgi

would speed up the time required to compile your application in the runtime.
would speed up the time required to compile your application in the runtime.
2 changes: 1 addition & 1 deletion 06_convert_cgi_apps_to_psgi.md
Expand Up @@ -27,4 +27,4 @@ This is a very simple CGI application, and converting this to PSGI is easy using

`psgi_header` is an utility method to work just like CGI's `header` method, and returns the status code and an array reference containing the list of HTTP headers.

Tomorrow, I'll talk about how to convert existing web frameworks that uses CGI.pm, using CGI::PSGI.
Tomorrow, I'll talk about how to convert existing web frameworks that uses CGI.pm, using CGI::PSGI.
1 change: 0 additions & 1 deletion 07_use_web_application_framework_in_psgi.md
Expand Up @@ -22,4 +22,3 @@ and use [plackup](http://advent.plackperl.org/2009/12/day-3-using-plackup.html)
Similarly, most web frameworks that "supports" PSGI provides a plugin, engine or adapter to make the framework run on PSGI mode. For instance, [Catalyst](http://www.catalystframework.org/) has a Catalyst::Engine::* web server abstraction and [Catalyst::Engine::PSGI](http://search.cpan.org/perldoc?Catalyst::Engine::PSGI) is the engine to adapt Catalyst to run on PSGI.

The point is that with "PSGI support" from web frameworks, your application doesn't need to be modified, most of the times any single lines of code. And then by switching to PSGI you'll have lots of benefits like being able to use toolchain like plackup, Plack::Test and middleware which we'll discuss later in the future advent entries.

2 changes: 1 addition & 1 deletion 08_adapting_web_frameworks_to_psgi.md
Expand Up @@ -120,4 +120,4 @@ Similarly Catalyst uses Catalyst::Engine abstraction and [Catalyst::Engine::PSGI

## mod_perl centric frameworks

Some frameworks are centered around mod_perl's API, in which case we can't take the approaches like we've seen here. Instead, you should probably start by mocking Apache::Request APIs using a fake/mock object. Patric Donelan, a WebGUI developer explains his approach to make mod_perl-like API in [his blog post](http://blog.patspam.com/2009/plack-roundup-at-sf-pm) that you might be interested in, and the [mock request class linked](http://github.com/pdonelan/webgui/blob/plebgui/lib/WebGUI/Session/Plack.pm) would be a good start.
Some frameworks are centered around mod_perl's API, in which case we can't take the approaches like we've seen here. Instead, you should probably start by mocking Apache::Request APIs using a fake/mock object. Patric Donelan, a WebGUI developer explains his approach to make mod_perl-like API in [his blog post](http://blog.patspam.com/2009/plack-roundup-at-sf-pm) that you might be interested in, and the [mock request class linked](http://github.com/pdonelan/webgui/blob/plebgui/lib/WebGUI/Session/Plack.pm) would be a good start.
3 changes: 1 addition & 2 deletions 10_using_plack_middleware.md
Expand Up @@ -4,7 +4,7 @@

Middleware is a concept in PSGI (as always, stolen from Python's WSGI and Ruby's Rack) where we define components that plays the both side of a server and an application.

![WSGI middleware onion](http://docs.pylonsproject.org/projects/pylons-webframework/en/latest/_images/pylons_as_onion.png)
![WSGI middleware onion](images/pylons_as_onion.png)

(Image courtesy of Pylons project for Python WSGI)

Expand Down Expand Up @@ -66,4 +66,3 @@ The beauty of Middleware is that it can wrap *any* PSGI application. It might no
};

This will enable the Basic authentication middleware to CGI::Application based application. You can do the same with [any other frameworks that supports PSGI](http://plackperl.org/#frameworks).

2 changes: 1 addition & 1 deletion 12_maps_multiple_apps_with_mount_and_urlmap.md
Expand Up @@ -85,4 +85,4 @@ Of course you can use this URLMap and mount API to run multiple framework applic
mount "/baz" => $app3;
};

And now you have three applications, each of which inherit from different web framework, running on the same server (via plackup or other Plack::Server::* implementations) mapped on different paths.
And now you have three applications, each of which inherit from different web framework, running on the same server (via plackup or other Plack::Server::* implementations) mapped on different paths.
1 change: 0 additions & 1 deletion 13_use_plack_test_to_test_your_application.md
Expand Up @@ -88,4 +88,3 @@ Once again, the beauty of PSGI and Plack is that everything written to run for t
done_testing;

You can of course do the same thing against any frameworks that supports PSGI.

2 changes: 1 addition & 1 deletion 14_use_plack_request.md
Expand Up @@ -33,4 +33,4 @@ Plack::Request is available as part of Plack on CPAN. Your framework can use Pla

Directly using Plack::Request in the `.psgi` code is quite handy to quickly write and test your code but not really recommended for a large scale application. It's exactly like writing a 1000 lines of `.cgi` script where you could factor out the application code into a module (`.pm` files). The same thing applies to `.psgi` file: it's best to create an application class by using and possibly extending Plack::Request, and then have just a few lines of code in `.psgi` file with [Plack::Builder to configure middleware components](http://advent.plackperl.org/2009/12/day-11-using-plackbuilder.html).

Plack::Request is also supposed to be used from a web application framework to [adapt to PSGI interface](http://advent.plackperl.org/2009/12/day-8-adapting-web-frameworks-to-psgi.html).
Plack::Request is also supposed to be used from a web application framework to [adapt to PSGI interface](http://advent.plackperl.org/2009/12/day-8-adapting-web-frameworks-to-psgi.html).
2 changes: 1 addition & 1 deletion 15_authenticate_your_app_with_middleware.md
Expand Up @@ -73,4 +73,4 @@ URLMap allows you to compound multiple apps into one app, so combined with Auth
mount "/public" => $app;
};

This way you run the same `$app` in "/public" and "/private" paths, while "/private" requires a basic authentication and "/public" doesn't. (Inlining `$env->{REMOTE_USER}`, or whatever application logic in .psgi is not really recommended -- i just used it to explain it in an obvious way)
This way you run the same `$app` in "/public" and "/private" paths, while "/private" requires a basic authentication and "/public" doesn't. (Inlining `$env->{REMOTE_USER}`, or whatever application logic in .psgi is not really recommended -- i just used it to explain it in an obvious way)
2 changes: 1 addition & 1 deletion 16_adding_jsonp_support_to_your_app.md
Expand Up @@ -64,4 +64,4 @@ And then using Catalyst::Engine::PSGI and Plack::Builder, you can add a JSONP su
$app;
};

Accidentally this [Catalyst::View::JSON](http://search.cpan.org/perldoc?Catalyst::View::JSON) is my module :) and supports JSONP callback configuration by default, but there is more than one way to do it!
Accidentally this [Catalyst::View::JSON](http://search.cpan.org/perldoc?Catalyst::View::JSON) is my module :) and supports JSONP callback configuration by default, but there is more than one way to do it!
2 changes: 1 addition & 1 deletion 17_serving_static_files_from_your_application.md
Expand Up @@ -39,4 +39,4 @@ Just like Perl there's more than one way to do it. When you grok how to use [mou
mount "/" => $app;
};

Your mileage may vary, but I think this one is more obvious. Static's callback based configuration allows you to write more complex regular expression, which you can't do with URLMap and mount, so choose whichever fits your need.
Your mileage may vary, but I think this one is more obvious. Static's callback based configuration allows you to write more complex regular expression, which you can't do with URLMap and mount, so choose whichever fits your need.
3 changes: 0 additions & 3 deletions 19_cascade_multiple_applications.md
Expand Up @@ -53,6 +53,3 @@ This application is mapped to `/static` using URLMap, and all requests will try
This will create two applications, one with Catalyst and the other with CGI::Application and runs two applications in order. Suppose you have an overlapping URL structure and `/what/ever.cat` served with the Catalyst application and `/what/ever.cgiapp` served with the CGI::Application app.

Well that might sound crazy and i guess it's better to use URLMap to map two applications in different paths, but if you *really want* to cascade them, this is the way to go :)

2 changes: 1 addition & 1 deletion 21_lint_your_application_and_middleware.md
Expand Up @@ -38,4 +38,4 @@ When you develop a new framework adapter or a middleware component, be sure to c

Middleware::Lint validates both request and response interface, so this can be used when you develop a new PSGI web server as well. However if you are a server developer there's a more comprehensive testing tool to make sure your server behaves correctly, and that is Plack::Test::Suite.

You can look at the existing tests in the `t/Plack-Server` directory for how to use this utility, but it defines lots of expected requests and responses pairs to test a new PSGI server backend. Existing Plack::Server backends included in Plack core distribution as well as other CPAN distributions all pass this test suite.
You can look at the existing tests in the `t/Plack-Server` directory for how to use this utility, but it defines lots of expected requests and responses pairs to test a new PSGI server backend. Existing Plack::Server backends included in Plack core distribution as well as other CPAN distributions all pass this test suite.
1 change: 0 additions & 1 deletion 22_discover_more_middleware.md
Expand Up @@ -75,4 +75,3 @@ Proxy middleware is developed by Lee Aylward on [github](http://github.com/leedo
### More

There are more middleware components available in the Plack distribution, and on [CPAN](http://search.cpan.org/search?query=plack+middleware&mode=dist). Not all middleware components are supposed to be great, but certainly they can be shared and used by most frameworks that support PSGI.

2 changes: 1 addition & 1 deletion 23_write_your_own_middleware.md
Expand Up @@ -108,4 +108,4 @@ Or use the non-DSL API,

$app = MyFramework::Middleware::Foo->wrap($app, ...);

and they should work just fine.
and they should work just fine.
4 changes: 2 additions & 2 deletions 24_wrap_up.md
Expand Up @@ -20,10 +20,10 @@ Most of the Plack gangs use [github](http://github.com/) for the source control

Again, Plack is a fairly young project. It's just been 3 months since we gave this project a birth. There are many things that could get more improvements, so if you come across one of them, don't stop there. Let us know what you think is a problem, give us an insight how it could be improved, or if you're impatient, fork the project on github and send us patches.

We're chatting on [IRC channel #plack on irc.perl.org](irc://irc.perl.org/#plack) and there's a [mailing list](http://groups.google.com/group/psgi-plack) and [an issue tracker on github](http://github.com/miyagawa/Plack/issues) to communicate with us.
We're chatting on IRC channel #plack on irc.perl.org and there's a [mailing list](http://groups.google.com/group/psgi-plack) and [an issue tracker on github](http://github.com/miyagawa/Plack/issues) to communicate with us.

### On a final note...

It's been an interesting experiment of writing 24 articles for 24 days, and I'm glad that I finished this myself. Next year, i'm looking forward to having your own advent entries to make the community based advent calendar.

I wish you a Very Merry Christmas and a Happy New Year.
I wish you a Very Merry Christmas and a Happy New Year.
Binary file added images/pylons_as_onion.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 706c2f5

Please sign in to comment.