Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Directives

MATSUMOTO, Ryosuke edited this page · 13 revisions
Clone this wiki locally

Directives

Writing Hooks by a Directive

General

Hook your ruby script each phrases. See directives.

Set file path

<Location /hello>
    mrubyHandlerMiddle /path/to/hello.rb
</Location>

Set file path and code cached

<Location /hello>
    mrubyHandlerMiddle /path/to/hello.rb cache
</Location>

Set inline code and code cached

<Location /hello>
    mrubyHandlerMiddleCode 'Apache.echo "hello world!"'
</Location>

Exceptional

Add handler

mrubyHandlerEnable is Off by defualt for .htaccess in Web Hosting Services.

mrubyHandlerEnable On
<Location /mruby-program>
    AddHandler mruby-script .rb
</Location>  

Output filter

<Location /filter>
    SetOutputFilter mruby
    mrubyOutputFilter /path/to/filter.rb
</Location>

Authenticate

Basic Auth
<Location /basic/>
    AuthType basic
    AuthName "Message for clients"
    AuthBasicProvider mruby
    mrubyAuthnCheckPassword /path/to/authn_basic.rb
    require valid-user
</Location>
Digest Auth
<Location /digest/>
    AuthType digest
    AuthName "hobbits"
    AuthBasicProvider mruby
    mrubyAuthnGetRealmHash /path/to/authn_digest.rb
    require valid-user
</Location>

Directive

The Directive which be implemented by mod_mruby is as follows.

Directive Hook Function Hook Ordering arg1 arg2(optinal)
mrubyHandler ap_hook_handler APR_HOOK_REALLY_FIRST file path "cache"
mrubyHandlerFirst ap_hook_handler APR_HOOK_FIRST file path "cache"
mrubyHandlerMiddle ap_hook_handler APR_HOOK_MIDDLE file path "cache"
mrubyHandlerLast ap_hook_handler APR_HOOK_LAST file path "cache"
mrubyPostConfigFirst ap_hook_post_config APR_HOOK_FIRST file path "cache"
mrubyPostConfigMiddle ap_hook_post_config APR_HOOK_MIDDLE file path "cache"
mrubyPostConfigLast ap_hook_post_config APR_HOOK_LAST file path "cache"
mrubyChildInitFirst ap_hook_child_init APR_HOOK_FIRST file path "cache"
mrubyChildInitMiddle ap_hook_child_init APR_HOOK_MIDDLE file path "cache"
mrubyChildInitLast ap_hook_child_init APR_HOOK_LAST file path "cache"
mrubyPostReadRequestFirst ap_hook_post_read_request APR_HOOK_FIRST file path "cache"
mrubyPostReadRequestMiddle ap_hook_post_read_request APR_HOOK_MIDDLE file path "cache"
mrubyPostReadRequestLast ap_hook_post_read_request APR_HOOK_LAST file path "cache"
mrubyQuickHandlerFirst ap_hook_quick_handler APR_HOOK_FIRST file path "cache"
mrubyQuickHandlerMiddle ap_hook_quick_handler APR_HOOK_MIDDLE file path "cache"
mrubyQuickHandlerLast ap_hook_quick_handler APR_HOOK_LAST file path "cache"
mrubyTranslateNameFirst ap_hook_translate_name APR_HOOK_FIRST file path "cache"
mrubyTranslateNameMiddle ap_hook_translate_name APR_HOOK_MIDDLE file path "cache"
mrubyTranslateNameLast ap_hook_translate_name APR_HOOK_LAST file path "cache"
mrubyMapToStorageFirst ap_hook_map_to_storage APR_HOOK_FIRST file path "cache"
mrubyMapToStorageMiddle ap_hook_map_to_storage APR_HOOK_MIDDLE file path "cache"
mrubyMapToStorageLast ap_hook_map_to_storage APR_HOOK_LAST file path "cache"
mrubyAccessCheckerFirst ap_hook_access_checker APR_HOOK_FIRST file path "cache"
mrubyAccessCheckerMiddle ap_hook_access_checker APR_HOOK_MIDDLE file path "cache"
mrubyAccessCheckerLast ap_hook_access_checker APR_HOOK_LAST file path "cache"
mrubyCheckUserIdFirst ap_hook_check_user_id APR_HOOK_FIRST file path "cache"
mrubyCheckUserIdMiddle ap_hook_check_user_id APR_HOOK_MIDDLE file path "cache"
mrubyCheckUserIdLast ap_hook_check_user_id APR_HOOK_LAST file path "cache"
mrubyAuthCheckerFirst ap_hook_auth_checker APR_HOOK_FIRST file path "cache"
mrubyAuthCheckerMiddle ap_hook_auth_checker APR_HOOK_MIDDLE file path "cache"
mrubyAuthCheckerLast ap_hook_auth_checker APR_HOOK_LAST file path "cache"
mrubyFixupsFirst ap_hook_fixups APR_HOOK_FIRST file path "cache"
mrubyFixupsMiddle ap_hook_fixups APR_HOOK_MIDDLE file path "cache"
mrubyFixupsLast ap_hook_fixups APR_HOOK_LAST file path "cache"
mrubyInsertFilterFirst ap_hook_insert_filter APR_HOOK_FIRST file path "cache"
mrubyInsertFilterMiddle ap_hook_insert_filter APR_HOOK_MIDDLE file path "cache"
mrubyInsertFilterLast ap_hook_insert_filter APR_HOOK_LAST file path "cache"
mrubyLogTransactionFirst ap_hook_log_transaction APR_HOOK_FIRST file path "cache"
mrubyLogTransactionMiddle ap_hook_log_transaction APR_HOOK_MIDDLE file path "cache"
mrubyLogTransactionLast ap_hook_log_transaction APR_HOOK_LAST file path "cache"
mrubyAuthnCheckPassword auth phase - file path "cache"
mrubyAuthnGetRealmHash auth phase - file path "cache"
mrubyOutputFilter output filter phase - file path "cache"

Hook Ordering

  • APR_HOOK_REALLY_FIRST ・・・ run this hook first, before ANYTHING

  • APR_HOOK_FIRST ・・・ run this hook first

  • APR_HOOK_MIDDLE ・・・ run this hook somewhere

  • APR_HOOK_LAST ・・・ run this hook after every other hook which is defined

  • APR_HOOK_REALLY_LAST ・・・ run this hook last, after EVERYTHING

Directive

mrubyPostReadRequestFirst

Description   : Provide a hook for the post_read_request phase of request processing
Hook Function : post_read_request
Hook Ordering : APR_HOOK_FIRST
Syntax        : mrubyPostReadRequestFirst /path/to/script.mrb
Type          : RUN_ALL
Module        : mod_mruby
Compatibility : 2.2 , 2.4

mrubyPostReadRequestMiddle

Description   : Provide a hook for the post_read_request phase of request processing
Hook Function : post_read_request
Hook Ordering : APR_HOOK_MIDDLE
Syntax        : mrubyPostReadRequestMiddle /path/to/script.mrb
Type          : RUN_ALL
Module        : mod_mruby
Compatibility : 2.2 , 2.4

mrubyPostReadRequestLast

Description   : Provide a hook for the post_read_request phase of request processing
Hook Function : post_read_request
Hook Ordering : APR_HOOK_Last
Syntax        : mrubyPostReadRequestLast /path/to/script.mrb
Type          : RUN_ALL
Module        : mod_mruby
Compatibility : 2.2 , 2.4

mrubyQuickHandlerFirst

Description   : Provide a hook for the quick_handler phase of request processing
Hook Function : quick_handler
Hook Ordering : APR_HOOK_FIRST
Syntax        : mrubyQuickHandlerFirst /path/to/script.mrb
Type          : RUN_FIRST
Module        : mod_mruby
Compatibility : 2.2 , 2.4

mrubyQuickHandlerMiddle

Description   : Provide a hook for the quick_handler phase of request processing
Hook Function : quick_handler
Hook Ordering : APR_HOOK_MIDDLE
Syntax        : mrubyQuickHandlerMiddle /path/to/script.mrb
Type          : RUN_FIRST
Module        : mod_mruby
Compatibility : 2.2 , 2.4

mrubyQuickHandlerLast

Description   : Provide a hook for the quick_handler phase of request processing
Hook Function : quick_handler
Hook Ordering : APR_HOOK_Last
Syntax        : mrubyQuickHandlerLast /path/to/script.mrb
Type          : RUN_FIRST
Module        : mod_mruby
Compatibility : 2.2 , 2.4

mrubyTranslateNameFirst

Description   : Provide a hook for the translate_name phase of request processing
Hook Function : translate_name
Hook Ordering : APR_HOOK_FIRST
Syntax        : mrubyTranslateNameFirst /path/to/script.mrb
Type          : RUN_FIRST
Module        : mod_mruby
Compatibility : 2.2 , 2.4

mrubyTranslateNameMiddle

Description   : Provide a hook for the translate_name phase of request processing
Hook Function : translate_name
Hook Ordering : APR_HOOK_MIDDLE
Syntax        : mrubyTranslateNameMiddle /path/to/script.mrb
Type          : RUN_FIRST
Module        : mod_mruby
Compatibility : 2.2 , 2.4

mrubyTranslateNameLast

Description   : Provide a hook for the translate_name phase of request processing
Hook Function : translate_name
Hook Ordering : APR_HOOK_Last
Syntax        : mrubyTranslateNameLast /path/to/script.mrb
Type          : RUN_FIRST
Module        : mod_mruby
Compatibility : 2.2 , 2.4

mrubyMapToStorageFirst

Description   : Provide a hook for the map_to_storage phase of request processing
Hook Function : map_to_storage
Hook Ordering : APR_HOOK_FIRST
Syntax        : mrubyMapToStorageFirst /path/to/script.mrb
Type          : RUN_FIRST
Module        : mod_mruby
Compatibility : 2.2 , 2.4

mrubyMapToStorageMiddle

Description   : Provide a hook for the map_to_storage phase of request processing
Hook Function : map_to_storage
Hook Ordering : APR_HOOK_MIDDLE
Syntax        : mrubyMapToStorageMiddle /path/to/script.mrb
Type          : RUN_FIRST
Module        : mod_mruby
Compatibility : 2.2 , 2.4

mrubyMapToStorageLast

Description   : Provide a hook for the map_to_storage phase of request processing
Hook Function : map_to_storage
Hook Ordering : APR_HOOK_Last
Syntax        : mrubyMapToStorageLast /path/to/script.mrb
Type          : RUN_FIRST
Module        : mod_mruby
Compatibility : 2.2 , 2.4

mrubyAccessCheckerFirst

Description   : Provide a hook for the access_checker phase of request processing
Hook Function : access_checker
Hook Ordering : APR_HOOK_FIRST
Syntax        : mrubyAccessCheckerFirst /path/to/script.mrb
Type          : RUN_ALL
Module        : mod_mruby
Compatibility : 2.2 , 2.4

mrubyAccessCheckerMiddle

Description   : Provide a hook for the access_checker phase of request processing
Hook Function : access_checker
Hook Ordering : APR_HOOK_MIDDLE
Syntax        : mrubyAccessCheckerMiddle /path/to/script.mrb
Type          : RUN_ALL
Module        : mod_mruby
Compatibility : 2.2 , 2.4

mrubyAccessCheckerLast

Description   : Provide a hook for the access_checker phase of request processing
Hook Function : access_checker
Hook Ordering : APR_HOOK_Last
Syntax        : mrubyAccessCheckerLast /path/to/script.mrb
Type          : RUN_ALL
Module        : mod_mruby
Compatibility : 2.2 , 2.4

mrubyCheckUserIdFirst

Description   : Provide a hook for the check_user_id phase of request processing
Hook Function : check_user_id
Hook Ordering : APR_HOOK_FIRST
Syntax        : mrubyCheckUserIdFirst /path/to/script.mrb
Type          : RUN_FIRST
Module        : mod_mruby
Compatibility : 2.2 , 2.4

mrubyCheckUserIdMiddle

Description   : Provide a hook for the check_user_id phase of request processing
Hook Function : check_user_id
Hook Ordering : APR_HOOK_MIDDLE
Syntax        : mrubyCheckUserIdMiddle /path/to/script.mrb
Type          : RUN_FIRST
Module        : mod_mruby
Compatibility : 2.2 , 2.4

mrubyCheckUserIdLast

Description   : Provide a hook for the check_user_id phase of request processing
Hook Function : check_user_id
Hook Ordering : APR_HOOK_Last
Syntax        : mrubyCheckUserIdLast /path/to/script.mrb
Type          : RUN_FIRST
Module        : mod_mruby
Compatibility : 2.2 , 2.4

mrubyAuthCheckerFirst

Description   : Provide a hook for the auth_checker phase of request processing
Hook Function : auth_checker
Hook Ordering : APR_HOOK_FIRST
Syntax        : mrubyAuthCheckerFirst /path/to/script.mrb
Type          : RUN_FIRST
Module        : mod_mruby
Compatibility : 2.2 , 2.4

mrubyAuthCheckerMiddle

Description   : Provide a hook for the auth_checker phase of request processing
Hook Function : auth_checker
Hook Ordering : APR_HOOK_MIDDLE
Syntax        : mrubyAuthCheckerMiddle /path/to/script.mrb
Type          : RUN_FIRST
Module        : mod_mruby
Compatibility : 2.2 , 2.4

mrubyAuthCheckerLast

Description   : Provide a hook for the auth_checker phase of request processing
Hook Function : auth_checker
Hook Ordering : APR_HOOK_Last
Syntax        : mrubyAuthCheckerLast /path/to/script.mrb
Type          : RUN_FIRST
Module        : mod_mruby
Compatibility : 2.2 , 2.4

mrubyFixupsFirst

Description   : Provide a hook for the fixups phase of request processing
Hook Function : fixups
Hook Ordering : APR_HOOK_FIRST
Syntax        : mrubyFixupsFirst /path/to/script.mrb
Type          : RUN_ALL
Module        : mod_mruby
Compatibility : 2.2 , 2.4

mrubyFixupsMiddle

Description   : Provide a hook for the fixups phase of request processing
Hook Function : fixups
Hook Ordering : APR_HOOK_MIDDLE
Syntax        : mrubyFixupsMiddle /path/to/script.mrb
Type          : RUN_ALL
Module        : mod_mruby
Compatibility : 2.2 , 2.4

mrubyFixupsLast Derective

Description   : Provide a hook for the fixups phase of request processing
Hook Function : fixups
Hook Ordering : APR_HOOK_Last
Syntax        : mrubyFixupsLast /path/to/script.mrb
Type          : RUN_ALL
Module        : mod_mruby
Compatibility : 2.2 , 2.4

mrubyInsertFilterFirst Derective

Description   : Provide a hook for the insert_filter phase of request processing
Hook Function : insert_filter
Hook Ordering : APR_HOOK_FIRST
Syntax        : mrubyInsertFilterFirst /path/to/script.mrb
Type          : VOID
Module        : mod_mruby
Compatibility : 2.2 , 2.4

mrubyInsertFilterMiddle Derective

Description   : Provide a hook for the insert_filter phase of request processing
Hook Function : insert_filter
Hook Ordering : APR_HOOK_MIDDLE
Syntax        : mrubyInsertFilterMiddle /path/to/script.mrb
Type          : VOID
Module        : mod_mruby
Compatibility : 2.2 , 2.4

mrubyInsertFilterLast Derective

Description   : Provide a hook for the insert_filter phase of request processing
Hook Function : insert_filter
Hook Ordering : APR_HOOK_Last
Syntax        : mrubyInsertFilterLast /path/to/script.mrb
Type          : VOID
Module        : mod_mruby
Compatibility : 2.2 , 2.4

mrubyHandler

Description   : Provide a hook for the handler phase of request processing
Hook Function : handler
Hook Ordering : APR_HOOK_REALLY_FIRST
Syntax        : mrubyHandler /path/to/script.mrb
Type          : RUN_FIRST
Module        : mod_mruby
Compatibility : 2.2 , 2.4

mrubyLogTransactionFirst

Description   : Provide a hook for the log_transaction phase of request processing
Hook Function : log_transaction
Hook Ordering : APR_HOOK_FIRST
Syntax        : mrubyLogTransactionFirst /path/to/script.mrb
Type          : RUN_ALL
Module        : mod_mruby
Compatibility : 2.2 , 2.4

mrubyLogTransactionMiddle

Description   : Provide a hook for the log_transaction phase of request processing
Hook Function : log_transaction
Hook Ordering : APR_HOOK_MIDDLE
Syntax        : mrubyLogTransactionMiddle /path/to/script.mrb
Type          : RUN_ALL
Module        : mod_mruby
Compatibility : 2.2 , 2.4

mrubyLogTransactionLast

Description   : Provide a hook for the log_transaction phase of request processing
Hook Function : log_transaction
Hook Ordering : APR_HOOK_Last
Syntax        : mrubyLogTransactionLast /path/to/script.mrb
Type          : RUN_ALL
Module        : mod_mruby
Compatibility : 2.2 , 2.4

About VOID, RUN_ALL and RUN_FIRST

  • VOID ・・・ Implement a hook that has no return code, and therefore runs all of the registered functions.

  • RUN_ALL ・・・ Implement a hook that runs until one of the functions returns something other than OK or DECLINE.

  • RUN_FIRST ・・・ Implement a hook that runs until the first function returns something other than the value of decline.

Something went wrong with that request. Please try again.