Perl的REST流布局 [英] Perl REST flow layout
问题描述
我使用的Apache和Perl(modperl),与处理程序来处理请求。我是新来这个,我不太清楚如何打好东西出来一个明智的方式。
I'm using Apache and Perl (modperl), with Handlers to handle requests. I'm new to this, and I'm not quite sure how to lay things out in a sensible way.
现在,我有以下几点:
package MyClass::Handler;
use warnings;
use strict;
# includes
our %action = (
'a' => \&a,
# And more
);
sub handler {
my $a = shift;
my $r = Apache2::Request->new($a);
# Do things
return Apache2::Const::OK();
}
我应该为每个空间不同的文件?使用计算器为模板,我需要为所有用户管理User.pm?一种故事Story.pm?
Should I have a different file for each "space"? Using stackoverflow as a template, do I need a User.pm for all the User management? A Story.pm for stories?
推荐答案
您可能会感兴趣的优秀的 CGI ::应用程序从CPAN框架。尽管它的名字,它的工作原理都在正常CGI和mod_perl的。它的设计,使建立web应用分派表很简单的任务。扔在<一个href=\"http://search.cpan.org/~markstos/CGI-Application-Dispatch-2.16/lib/CGI/Application/Dispatch.pm\"相对=nofollow> CGI ::应用::派遣,你会得到很好的REST样的URL。
You might be interested in the excellent CGI::Application framework from CPAN. Despite its name, it works both under normal CGI and mod_perl. It's designed to make the task of setting up web-app dispatch tables very simple. Throw in CGI::Application::Dispatch and you get nice REST-like URLs.
这篇关于Perl的REST流布局的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!