GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Mason::Manual::RequestDispatch(3) User Contributed Perl Documentation Mason::Manual::RequestDispatch(3)

Mason::Manual::RequestDispatch - How request paths get mapped to page components

Given the request path

    /news/sports/hockey

Mason searches for the following components in order, setting $m->path_info as noted.

    /news/sports/hockey.{mp,mc}
    /news/sports/hockey/index.{mp,mc}
    /news/sports/hockey/dhandler.{mp,mc}
    /news/sports/dhandler.{mp,mc}  # $m->path_info = hockey
    /news/sports.{mp,mc}           # $m->path_info = hockey (but see next section)
    /news/dhandler.{mp,mc}         # $m->path_info = sports/hockey
    /news.{mp,mc}                  # $m->path_info = sports/hockey (but see next section)
    /dhandler.{mp,mc}              # $m->path_info = news/sports/hockey

where ".{mp,mc}" means either ".mp" (indicating a pure-perl component). or ".mc" (indicating a top-level component).

The following sections describe these elements in more detail.

The request path is suffixed with ".mp" and ".mc" to translate it to a component path.

    /news/sports/hockey.{mp,mc}

An index matches its exact directory, nothing underneath.

    /news/sports/hockey/index.{mp,mc}

A dhandler matches its directory as well as anything underneath, setting "$m->path_info" to the remainder.

    /news/sports/hockey/dhandler.{mp,mc}
    /news/sports/dhandler.{mp,mc}  # $m->path_info = hockey
    /news/dhandler.{mp,mc}         # $m->path_info = sports/hockey
    /dhandler.{mp,mc}              # $m->path_info = news/sports/hockey

A component can match an initial part of the URL, setting "$m->path_info" to the remainder:

    /news/sports.{mp,mc}           # $m->path_info = hockey
    /news.{mp,mc}                  # $m->path_info = sports/hockey

Since this isn't always desirable behavior, it must be explicitly enabled for the component. Mason will call method "allow_path_info" on the component class, and will only allow the match if it returns true:

    <%class>
    method allow_path_info { 1 }
    </%class>

The default "allow_path_info" returns false.

"allow_path_info" is not checked on dhandlers, since the whole point of dhandlers is to match partial paths.

If the request URL has a trailing slash (ends with "/"), we remove it before the match process begins and add it to the "$m->path_info". Components that should match must have "allow_path_info" return true.

For example:

    ## request URL /news/
    /news/index.{mp,mc}     # $m->path_info = / if index.{mp,mc} has
                            # allow_path_info => true
    /news/dhandler.{mp,mc}  # $m->path_info = /
    /news.{mp,mc}           # $m->path_info = / if news.{mp,mc} has
                            # allow_path_info => true

    ## request URL /news/sports/
    /news/sports/index.{mp,mc}     # $m->path_info = / if index.{mp,mc} has
                                   # allow_path_info => true
    /news/sports/dhandler.{mp,mc}  # $m->path_info = /
    /news/sports.{mp,mc}           # $m->path_info = / if sports.{mp,mc}
                                   # has allow_path_info => true
    /news/dhandler.{mp,mc}         # $m->path_info = sports/
    /news.{mp,mc}                  # $m->path_info = /sports/ if news.{mp,mc}
                                   # has allow_path_info => true

It is possible to use route syntax to more elegantly parse "$m->path_info" for dhandlers and partial paths, e.g.

    <%class>
    route "{year:[0-9]+}/{month:[0-9]{2}}";
    </%class>

See Mason::Plugin::RouterSimple.

Mason

Jonathan Swartz <swartz@pobox.com>

This software is copyright (c) 2012 by Jonathan Swartz.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.

2015-05-16 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.