X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=slides.html;h=82551cb89ade45a7b99826269c34a84bd1f439d8;hb=ff14cb99a851c0c6bdec501e935d95033308cd5a;hp=5781fc8c771872a822103ff5aea0e17d69688726;hpb=499f996ae29359b7fd5179cad7e6cb367023354d;p=chaz%2Ftalk-introduction-to-psgi diff --git a/slides.html b/slides.html index 5781fc8..82551cb 100644 --- a/slides.html +++ b/slides.html @@ -198,7 +198,7 @@ If you're a developer writing a web app, you're probably asking why then you sho - New skills make you more marketable. -- -- So that you it when you see PSGI exposed through your web framework. +- So that you understand it when you see PSGI exposed through your web framework. -- - You can do cool things with PSGI! @@ -216,7 +216,7 @@ layout: true --- -### Hypertext Transfer Protocol +### **H**yper**t**ext **T**ransfer **P**rotocol -- - Invented by Tim Berners-Lee in 1989, first specified as [HTTP 0.9](https://www.w3.org/Protocols/HTTP/AsImplemented.html) in 1991. @@ -241,7 +241,7 @@ RFC 2616 was then superceded in 2014 by: --- -.col[ +.col.marginfix[ ### Request ```http @@ -253,7 +253,7 @@ Connection: Keep-Alive ``` ] -.col[ +.col.marginfix[ ### Response ```http @@ -270,7 +270,7 @@ Your IP address is 127.0.0.1. --- -.col[ +.col.marginfix[ ### Request ```http @@ -282,7 +282,7 @@ Connection: Keep-Alive ``` ] -.col[ +.col.marginfix[ ### Response ```http @@ -307,7 +307,7 @@ Your IP address is 127.0.0.1. --- -.col[ +.col.marginfix[ ### Request ```http @@ -319,7 +319,7 @@ GET /ip HTTP/1.1 ``` ] -.col[ +.col.marginfix[ ### Response ```http @@ -341,7 +341,7 @@ Your IP address is 127.0.0.1. --- -.col[ +.col.marginfix[ ### Request ```http @@ -353,7 +353,7 @@ Connection: Keep-Alive ``` ] -.col[ +.col.marginfix[ ### Response ```http @@ -376,7 +376,7 @@ Your IP address is 127.0.0.1. --- -.col[ +.col.marginfix[ ### Request ```http @@ -388,7 +388,7 @@ Connection: Keep-Alive ``` ] -.col[ +.col.marginfix[ ### Response ```http @@ -415,7 +415,7 @@ Your IP address is 127.0.0.1. --- -.col[ +.col.marginfix[ ### Request ```http @@ -427,7 +427,7 @@ Connection: Keep-Alive ``` ] -.col[ +.col.marginfix[ ### Response ```http @@ -455,7 +455,7 @@ Your IP address is 127.0.0.1. --- -.col[ +.col.marginfix[ ### Request ```http @@ -467,7 +467,7 @@ Connection: Keep-Alive ``` ] -.col[ +.col.marginfix[ ### Response ```http @@ -542,7 +542,7 @@ layout: true --- -### Common Gateway Interface +### **C**ommon **G**ateway **I**nterface -- - Created by the NCSA in 1993. @@ -579,31 +579,34 @@ print "Your IP address is ${client_ip}."; 1. Gateway sets information about the request in the environment. -.condensed[ +.condensed.marginfix[ .col[ -- AUTH_TYPE -- CONTENT_LENGTH -- CONTENT_TYPE -- GATEWAY_INTERFACE -- PATH_INFO -- PATH_TRANSLATED -- QUERY_STRING -- REMOTE_ADDR -- REMOTE_HOST +- `AUTH_TYPE` +- `CONTENT_LENGTH` +- `CONTENT_TYPE` +- `GATEWAY_INTERFACE` +- `PATH_INFO` +- `PATH_TRANSLATED` +- `QUERY_STRING` +- `REMOTE_ADDR` +- `REMOTE_HOST` ] .col[ -- REMOTE_IDENT -- REMOTE_USER -- REQUEST_METHOD -- SCRIPT_NAME -- SERVER_NAME -- SERVER_PORT -- SERVER_PROTOCOL -- SERVER_SOFTWARE +- `REMOTE_IDENT` +- `REMOTE_USER` +- `REQUEST_METHOD` +- `SCRIPT_NAME` +- `SERVER_NAME` +- `SERVER_PORT` +- `SERVER_PROTOCOL` +- `SERVER_SOFTWARE` - other "protocol-specific" variables ] ] +??? +- If you've done some web programming before, you're probably familiar with at least a few of these. + --- ```perl @@ -619,11 +622,11 @@ print "Your IP address is ${client_ip}."; 1. Gateway sets information about the request in the environment. 2. Print response headers to `STDOUT`. -.condensed[ +.condensed.marginfix[ .col[ -- Content-Type -- Location -- Status +- `Content-Type` +- `Location` +- `Status` - other "protocol-specific" header fields ] ] @@ -1050,6 +1053,8 @@ layout: false --- +class: plack + ## Plack - Provides tools for building, running, and testing PSGI apps. @@ -1196,118 +1201,118 @@ layout: true --- -.condensed[ +.condensed.marginfix[ .col[ -- HTTP_ACCEPT -- HTTP_ACCEPT_ENCODING -- HTTP_ACCEPT_LANGUAGE -- HTTP_CACHE_CONTROL -- HTTP_CONNECTION -- HTTP_DNT -- HTTP_HOST -- HTTP_USER_AGENT -- PATH_INFO -- QUERY_STRING -- REMOTE_ADDR -- REMOTE_PORT -- REQUEST_METHOD -- REQUEST_URI -- SCRIPT_NAME +- `HTTP_ACCEPT` +- `HTTP_ACCEPT_ENCODING` +- `HTTP_ACCEPT_LANGUAGE` +- `HTTP_CACHE_CONTROL` +- `HTTP_CONNECTION` +- `HTTP_DNT` +- `HTTP_HOST` +- `HTTP_USER_AGENT` +- `PATH_INFO` +- `QUERY_STRING ` +- `REMOTE_ADDR` +- `REMOTE_PORT` +- `REQUEST_METHOD` +- `REQUEST_URI` +- `SCRIPT_NAME` ] .col[ -- SERVER_NAME -- SERVER_PORT -- SERVER_PROTOCOL -- psgi.errors -- psgi.input -- psgi.multiprocess -- psgi.multithread -- psgi.nonblocking -- psgi.run_once -- psgi.streaming -- psgi.url_scheme -- psgi.version -- psgix.harakiri -- psgix.input.buffered -- psgix.io +- `SERVER_NAME` +- `SERVER_PORT` +- `SERVER_PROTOCOL` +- `psgi.errors` +- `psgi.input` +- `psgi.multiprocess` +- `psgi.multithread` +- `psgi.nonblocking` +- `psgi.run_once` +- `psgi.streaming` +- `psgi.url_scheme` +- `psgi.version` +- `psgix.harakiri` +- `psgix.input.buffered` +- `psgix.io` ] ] --- -.condensed[ +.condensed.marginfix[ .col[ -- .highlight[HTTP_ACCEPT] -- .highlight[HTTP_ACCEPT_ENCODING] -- .highlight[HTTP_ACCEPT_LANGUAGE] -- .highlight[HTTP_CACHE_CONTROL] -- .highlight[HTTP_CONNECTION] -- .highlight[HTTP_DNT] -- .highlight[HTTP_HOST] -- .highlight[HTTP_USER_AGENT] -- .highlight[PATH_INFO] -- .highlight[QUERY_STRING ] -- .highlight[REMOTE_ADDR] -- .highlight[REMOTE_PORT] -- .highlight[REQUEST_METHOD] -- .highlight[REQUEST_URI] -- .highlight[SCRIPT_NAME] +- .highlight[`HTTP_ACCEPT`] +- .highlight[`HTTP_ACCEPT_ENCODING`] +- .highlight[`HTTP_ACCEPT_LANGUAGE`] +- .highlight[`HTTP_CACHE_CONTROL`] +- .highlight[`HTTP_CONNECTION`] +- .highlight[`HTTP_DNT`] +- .highlight[`HTTP_HOST`] +- .highlight[`HTTP_USER_AGENT`] +- .highlight[`PATH_INFO`] +- .highlight[`QUERY_STRING `] +- .highlight[`REMOTE_ADDR`] +- .highlight[`REMOTE_PORT`] +- .highlight[`REQUEST_METHOD`] +- .highlight[`REQUEST_URI`] +- .highlight[`SCRIPT_NAME`] ] .col[ -- .highlight[SERVER_NAME] -- .highlight[SERVER_PORT] -- .highlight[SERVER_PROTOCOL] -- psgi.errors -- psgi.input -- psgi.multiprocess -- psgi.multithread -- psgi.nonblocking -- psgi.run_once -- psgi.streaming -- psgi.url_scheme -- psgi.version -- psgix.harakiri -- psgix.input.buffered -- psgix.io +- .highlight[`SERVER_NAME`] +- .highlight[`SERVER_PORT`] +- .highlight[`SERVER_PROTOCOL`] +- `psgi.errors` +- `psgi.input` +- `psgi.multiprocess` +- `psgi.multithread` +- `psgi.nonblocking` +- `psgi.run_once` +- `psgi.streaming` +- `psgi.url_scheme` +- `psgi.version` +- `psgix.harakiri` +- `psgix.input.buffered` +- `psgix.io` ] ] --- -.condensed[ +.condensed.marginfix[ .col[ -- HTTP_ACCEPT -- HTTP_ACCEPT_ENCODING -- HTTP_ACCEPT_LANGUAGE -- HTTP_CACHE_CONTROL -- HTTP_CONNECTION -- HTTP_DNT -- HTTP_HOST -- HTTP_USER_AGENT -- PATH_INFO -- QUERY_STRING -- REMOTE_ADDR -- REMOTE_PORT -- REQUEST_METHOD -- REQUEST_URI -- SCRIPT_NAME +- `HTTP_ACCEPT` +- `HTTP_ACCEPT_ENCODING` +- `HTTP_ACCEPT_LANGUAGE` +- `HTTP_CACHE_CONTROL` +- `HTTP_CONNECTION` +- `HTTP_DNT` +- `HTTP_HOST` +- `HTTP_USER_AGENT` +- `PATH_INFO` +- `QUERY_STRING ` +- `REMOTE_ADDR` +- `REMOTE_PORT` +- `REQUEST_METHOD` +- `REQUEST_URI` +- `SCRIPT_NAME` ] .col[ -- SERVER_NAME -- SERVER_PORT -- SERVER_PROTOCOL -- .highlight[psgi.errors] -- .highlight[psgi.input] -- .highlight[psgi.multiprocess ] -- .highlight[psgi.multithread ] -- .highlight[psgi.nonblocking ] -- .highlight[psgi.run_once ] -- .highlight[psgi.streaming] -- .highlight[psgi.url_scheme] -- .highlight[psgi.version] -- .highlight[psgix.harakiri] -- .highlight[psgix.input.buffered] -- .highlight[psgix.io] +- `SERVER_NAME` +- `SERVER_PORT` +- `SERVER_PROTOCOL` +- .highlight[`psgi.errors`] +- .highlight[`psgi.input`] +- .highlight[`psgi.multiprocess`] +- .highlight[`psgi.multithread`] +- .highlight[`psgi.nonblocking`] +- .highlight[`psgi.run_once`] +- .highlight[`psgi.streaming`] +- .highlight[`psgi.url_scheme`] +- .highlight[`psgi.version`] +- .highlight[`psgix.harakiri`] +- .highlight[`psgix.input.buffered`] +- .highlight[`psgix.io`] ] ] @@ -1338,6 +1343,16 @@ layout: true --- +name: middleware-debug + +### [`Debug`](https://metacpan.org/pod/Plack::Middleware::Debug) + +```perl +enable 'Debug'; +``` + +--- + ### [`ReverseProxy`](https://metacpan.org/pod/Plack::Middleware::ReverseProxy) ```perl @@ -1371,7 +1386,7 @@ enable 'LogDispatch', logger => $logger; ### [`XSRFBlock`](https://metacpan.org/pod/Plack::Middleware::XSRFBlock) ```perl -enable 'XSRFBlock'; +enable 'XSRFBlock', cookie_options => { httponly => 1 }; ``` - Blocking cross-site request forgery couldn't be easier. @@ -1395,7 +1410,7 @@ layout: false ![CPAN](img/cpan.png) ] -## Plack modules on the CPAN in July 2016 +## Plack modules in July 2016 **10** `Plack-Handler-*` distributions @@ -1407,7 +1422,17 @@ layout: false ## Parting Thoughts -- You should write middleware! +- PSGI also specifies a way to delay or stream responses to the server. + +??? +- It's kind of complicated, but you can read the spec to learn more. +- Read the source code of various apps and middlewares to see how it works in practice. + +-- +- There are tons of great apps and middleware on the CPAN. + +-- +- Consider writing some of your app as a middleware. ??? - The concept and implementation of middleware is cool. @@ -1418,13 +1443,7 @@ layout: false - Logging - Error handling - Sessions - --- -- PSGI also specifies a way to delay or stream responses to the server. - -??? -- It's kind of complicated, but you can read the spec to learn more. -- Read the source code of various apps and middlewares to see how it works in practice. + - Rate limiters --- @@ -1452,7 +1471,6 @@ name: last ## Thank you Email me: Charles McGarvey - .talkqr.center[ @@ -1472,5 +1490,5 @@ Leave me feedback, if you want: ] ] - +