kabanoid / plack-dispatching-samples Goto Github PK
View Code? Open in Web Editor NEWThis project forked from miyagawa/plack-dispatching-samples
Examples of Plack dispatcher using various CPAN modules
This project forked from miyagawa/plack-dispatching-samples
Examples of Plack dispatcher using various CPAN modules
This is a collection of URI dispatching example code using Plack::Request/Response and various dispatcher modules on CPAN. Most examples would do: GET / => "Hello World" in text/plain GET /blog/{year}/{month} => Get the list of blog posts in year/month POST /comment => Post a comment with parameters id, name and body Nice to have: /blog/{year}/{month} should be limited to 4-digit year and 2-digit month POST to GET-only endpoints should raise 405 You can run tests against the dispatcher using: perl tester.pl <dispatcher.psgi> NOTES This is NOT a check-no-check comparison. This is NOT a golf contest either. When it says "Can't do ...", it doesn't necessarily mean a minus - it means it's application's responsibility, which could mean more flexibilities. Also, the requirement "POST to GET-only endpoint should give 405" is nice to have, while in many cases it's not a fair game to add to dispatcher, because if the dispatcher supports that, there's no way to distinguish with non-existent paths (404) and if the dispatcher DOESN'T support that it becomes app's responsibility which could be easy. dancer: (Dancer doesn't use Plack::Request -- here's for the comparison) Can use named capture and regexp based dispatching POST to GET endpoints gives 404 by default HTTP::Router::Declare: Can dispatch using HTTP methods as well (You can remove { method => 'GET' } requirement to make 405 fallbacks work) Can specify requirement like routes.py HTTPx::Dispatcher: Can't use HTTP method as a dispatcher rule - it's an app's responsibility Can't use regular expressions / requirements Mojolicious::Lite: (Mojolicious doesn't use Plack::Request -- here's for the comparison) Can use named capture + regexp requirement like Merb / HTTP::Router POST to GET endpoints gives 404 by default Path::Dispatcher: Passing PSGI env to the metadata for REQUEST_METHOD matching (You can omit that to make 405 fallbacks on the app work) Path::Router: Can use Moose based constraints to validate path chunks Can't use HTTP method as a dispatcher rule - it's an app's reponsibility Tatsumaki: Can't use HTTP method as a dispatcher rule - app handlers need to define the verbs Default '/' is catch-all as of 0.1009 -- needs to be qr/^\/$/ (will be fixed in 0.1010) The mapping order matters -- sometimes confusing Web::Simple: Can't use regexp for dispatcher rules -- app's responsibility
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.