? my $ctx = $main::context; ? $_mt->wrapper_file("wrapper.mt", "Configure", "Mruby Directives")->(sub {
The following are the configuration directives of the mruby handler. Please refer to Using mruby to find out how to write handlers using mruby.
$ctx->{directive}->( name => "mruby.handler", levels => [ qw(path) ], see_also => render_mt(<<'EOT'),mruby.handler-file
EOT
desc => <<'EOT',
Upon start-up evaluates given mruby expression, and uses the returned mruby object to handle the incoming requests.
EOT
)->(sub {
?>
= $ctx->{example}->('Hello-world in mruby', <<'EOT')
mruby.handler: |
Proc.new do |env|
[200, {'content-type' => 'text/plain'}, ["Hello world\n"]]
end
EOT
?>
Note that the provided expression is evaluated more than once (typically for every thread that accepts incoming connections).
? }) $ctx->{directive}->( name => "mruby.handler-file", levels => [ qw(path) ], see_also => render_mt(<<'EOT'),mruby.handler
EOT
desc => <<'EOT',
Upon start-up evaluates given mruby file, and uses the returned mruby object to handle the incoming requests.
EOT
)->(sub {
?>
= $ctx->{example}->('Hello-world in mruby', <<'EOT')
mruby.handler-file: /path/to/my-mruby-handler.rb
EOT
?>
Note that the provided expression is evaluated more than once (typically for every thread that accepts incoming connections).
? }) ? })