=encoding utf8 =head1 NAME =begin original Mojolicious::Lite - Micro real-time web framework =end original Mojolicious::Lite - 小さなリアルタイムWebフレームワーク =head1 SYNOPSIS (使い方) =begin original # Automatically enables "strict", "warnings", "utf8" and Perl 5.10 features use Mojolicious::Lite; =end original # Mojolicious::Liteを使うと"strict","warnings","utf8","Perl 5.10 機能"が有効になる use Mojolicious::Lite; =begin original # Route with placeholder get '/:foo' => sub { my $c = shift; my $foo = $c->param('foo'); $c->render(text => "Hello from $foo."); }; =end original # プレースホルダーを使ったルーティング get '/:foo' => sub { my $c = shift; my $foo = $c->param('foo'); $c->render(text => "Hello from $foo."); }; =begin original # Start the Mojolicious command system app->start; =end original # Mojoliciousのコマンドシステムの開始 app->start; =head1 DESCRIPTION (説明) =begin original L is a tiny domain specific language built around L, made up of only about a dozen Perl functions. =end original Lは、10 個ほどの Perl 関数で作る、Lを中心にして構築された小さなドメイン指定言語です。 =begin original On Perl 5.20+ you can also use a C<-signatures> flag to enable support for L. =end original Perl 5.20以上の場合は、C<-signatures>フラグを使うことによりLを有効にできます。 use Mojolicious::Lite -signatures; get '/:foo' => sub ($c) { my $foo = $c->param('foo'); $c->render(text => "Hello from $foo."); }; app->start; =begin original See L for more! =end original より多くを知りたい場合は、Lを見てください。 =head1 GROWING (成長) =begin original While L will give you a detailed introduction to growing a L prototype into a well-structured L application, here we have collected a few snippets that illustrate very well just how similar both of them are. =end original Lは、Lプロトタイプをよく構成されたLに成長させるための詳細なイントロダクションとなっていますが、それが、どれくらいよく似ているかを示すために、いくつかのスニペットを集めました。 =head2 Routes (ルーティング) =begin original The functions L, L and friends all have equivalent methods. =end original L, L 関数とその仲間は、まったく同じです。 # Mojolicious::Lite get '/foo' => sub { my $c = shift; $c->render(text => 'Hello World!'); }; # Mojolicious sub startup { my $self = shift; my $routes = $self->routes; $routes->get('/foo' => sub { my $c = shift; $c->render(text => 'Hello World!'); }); } =head2 Application (アプリケーション) =begin original The application object you can access with the function L is the first argument passed to the C method. =end original L 関数でアクセスできるアプリケーションオブジェクトは C メソッドに渡される最初の引数です。 # Mojolicious::Lite app->max_request_size(16777216); # Mojolicious sub startup { my $self = shift; $self->max_request_size(16777216); } =head2 Plugins (プラグイン) =begin original Instead of the L function you just use the method L. =end original L 関数の代わりに、L メソッドを使うだけです。 # Mojolicious::Lite plugin 'Config'; # Mojolicious sub startup { my $self = shift; $self->plugin('Config'); } =head2 Helpers (ヘルパー) =begin original Similar to plugins, instead of the L function you just use the method L. =end original プラグインと似ていて、L 関数の代わりに L メソッドを使うだけです。 # Mojolicious::Lite helper two => sub { my $c = shift; return 1 + 1; }; # Mojolicious sub startup { my $self = shift; $self->helper(two => sub { my $c = shift; return 1 + 1; }); } =head2 Under (アンダー) =begin original Instead of sequential function calls, we can use methods to build a tree with nested routes, that much better illustrates how routes work internally. =end original 後に続く関数の呼び出しの代わりに、ネストされたルートで木を構築するためのメソッドを使うことができます。 # Mojolicious::Lite under '/foo'; get '/bar' => sub {...}; # Mojolicious sub startup { my $self = shift; my $routes = $self->routes; my $foo = $routes->under('/foo'); $foo->get('/bar' => sub {...}); } =head1 FUNCTIONS (関数) =begin original L implements the following functions, which are automatically exported. =end original Lは次の関数を実装しています。 =head2 any my $route = any '/:foo' => sub {...}; my $route = any '/:foo' => sub {...} => 'name'; my $route = any '/:foo' => {foo => 'bar'} => sub {...}; my $route = any '/:foo' => [foo => qr/\w+/] => sub {...}; my $route = any ['GET', 'POST'] => '/:foo' => sub {...}; my $route = any ['GET', 'POST'] => '/:foo' => [foo => qr/\w+/] => sub {...}; my $route = any ['GET', 'POST'] => '/:foo' => (agent => qr/Firefox/) => sub {...}; =begin original Generate route with L, matching any of the listed HTTP request methods or all. See L and L for more information. =end original Lによるルーティングを 生成し、リストされたHTTPのリクエストメソッドにマッチします。 さらなる引数のバリエーションについてはLを見てください。 =head2 app my $app = app; =begin original Returns the L application object, which is a subclass of L. =end original Lアプリケーションです; これは、Lのサブクラスです。 =begin original # Use all the available attributes and methods app->log->level('error'); app->defaults(foo => 'bar'); =end original # すべての利用可能な属性とメソッドが利用できます app->log->level('error'); app->defaults(foo => 'bar'); =head2 del my $route = del '/:foo' => sub {...}; my $route = del '/:foo' => sub {...} => 'name'; my $route = del '/:foo' => {foo => 'bar'} => sub {...}; my $route = del '/:foo' => [foo => qr/\w+/] => sub {...}; my $route = del '/:foo' => (agent => qr/Firefox/) => sub {...}; =begin original Generate route with L, matching only C requests. See L and L for more information. =end original Lによるルーティングを生成し、Cリクエストにだけマッチします。 さらなる引数のバリエーションについてはLとL を見てください。 =head2 get my $route = get '/:foo' => sub {...}; my $route = get '/:foo' => sub {...} => 'name'; my $route = get '/:foo' => {foo => 'bar'} => sub {...}; my $route = get '/:foo' => [foo => qr/\w+/] => sub {...}; my $route = get '/:foo' => (agent => qr/Firefox/) => sub {...}; =begin original Generate route with L, matching only C requests. See L and L for more information. =end original Lによるルーティングを生成し、Cリクエストにだけマッチします。 さらなる引数のバリエーションについてはLとLを見てください。 =head2 group group {...}; =begin original Start a new route group. =end original 新しいルーティングのグループを開始します。 =head2 helper helper foo => sub {...}; =begin original Add a new helper with L. =end original Lを使って新しいヘルパーを追加します。 =head2 hook hook after_dispatch => sub {...}; =begin original Share code with L. =end original Lと同じです。 =head2 options my $route = options '/:foo' => sub {...}; my $route = options '/:foo' => sub {...} => 'name'; my $route = options '/:foo' => {foo => 'bar'} => sub {...}; my $route = options '/:foo' => [foo => qr/\w+/] => sub {...}; my $route = options '/:foo' => (agent => qr/Firefox/) => sub {...}; =begin original Generate route with L, matching only C requests. See L and L for more information. =end original Lによるルーティングを生成し、Cリクエストにだけマッチします。 さらなる情報については LとLを見てください。 =head2 patch my $route = patch '/:foo' => sub {...}; my $route = patch '/:foo' => sub {...} => 'name'; my $route = patch '/:foo' => {foo => 'bar'} => sub {...}; my $route = patch '/:foo' => [foo => qr/\w+/] => sub {...}; my $route = patch '/:foo' => (agent => qr/Firefox/) => sub {...}; =begin original Generate route with L, matching only C requests. See L and L for more information. =end original Lによるルーティングを生成し、Cリクエストにだけマッチします。 さらなる情報については LとLを見てください。 =head2 plugin plugin SomePlugin => {foo => 23}; =begin original Load a plugin with L. =end original Lを使ってプラグインをロードします。 =head2 post my $route = post '/:foo' => sub {...}; my $route = post '/:foo' => sub {...} => 'name'; my $route = post '/:foo' => {foo => 'bar'} => sub {...}; my $route = post '/:foo' => [foo => qr/\w+/] => sub {...}; my $route = post '/:foo' => (agent => qr/Firefox/) => sub {...}; =begin original Generate route with L, matching only C requests. See L and L for more information. =end original Lによるルーティングを生成し、Cリクエストにだけマッチします。 さらなる情報については LとLを見てください。 =head2 put my $route = put '/:foo' => sub {...}; my $route = put '/:foo' => sub {...} => 'name'; my $route = put '/:foo' => {foo => 'bar'} => sub {...}; my $route = put '/:foo' => [foo => qr/\w+/] => sub {...}; my $route = put '/:foo' => (agent => qr/Firefox/) => sub {...}; =begin original Generate route with L, matching only C requests. See L and L for more information. =end original Lによるルーティングを生成し、Cリクエストにだけマッチします。 さらなる情報については LとLを見てください。 =head2 under my $route = under sub {...}; my $route = under '/:foo' => sub {...}; my $route = under '/:foo' => {foo => 'bar'}; my $route = under '/:foo' => [foo => qr/\w+/]; my $route = under '/:foo' => (agent => qr/Firefox/); my $route = under [format => 0]; =begin original Generate nested route with L, to which all following routes are automatically appended. See L and L for more information. =end original Lでブリッジを生成し、すべての続くルーティングに自動的に処理が追加されます。 さらなる情報については LとLを見てください。 =head2 websocket my $route = websocket '/:foo' => sub {...}; my $route = websocket '/:foo' => sub {...} => 'name'; my $route = websocket '/:foo' => {foo => 'bar'} => sub {...}; my $route = websocket '/:foo' => [foo => qr/\w+/] => sub {...}; my $route = websocket '/:foo' => (agent => qr/Firefox/) => sub {...}; =begin original Generate route with L, matching only WebSocket handshakes. See L and L for more information. =end original Lでルーティングを生成し、WebSocket ハンドシェイクにだけマッチします。 さらなる情報については LとLを見てください。 =head1 ATTRIBUTES (属性) =begin original L inherits all attributes from L. =end original LはLからすべての属性を継承しています。 =head1 METHODS (メソッド) =begin original L inherits all methods from L. =end original LはLからすべてのメソッドを継承しています。 =head1 SEE ALSO L, L, L. =begin meta Translate: 木本裕紀 Translate: 前山将人 Update: SHIRAKATA Kentaro (8.12) Status: in progress =end meta =cut