NAME

ASP4x::Router - URL Routing for your ASP4 web application.

SYNOPSIS

httpd.conf

<Perl>
  push @INC, '/path/to/yoursite.com/lib';
</Perl>

PerlModule ASP4x::Router

...

<VirtualHost *:80>
...
  PerlTransHandler ASP4x::Router
...
</VirtualHost>

asp4-config.json

...
"web": {
  ...
  "request_filters": [
    ...
    {
      "uri_match": "/.*",
      "class":     "ASP4x::Router"
    }
    ...
  ]
  ...
  "routes": [
    {
      "name":   "CreatePage",
      "path":   "/main/:type/create",
      "target": "/pages/create.asp",
      "method": "GET"
    },
    {
      "name":   "Create",
      "path":   "/main/:type/create",
      "target": "/handlers/dev.create",
      "method": "POST"
    },
    {
      "name":   "View",
      "path":   "/main/:type/{id:\\d+}",
      "target": "/pages/view.asp",
      "method": "*"
    },
    {
      "name":   "EditPage",
      "path":   "/main/:type/{id:\\d+}/edit",
      "target": "/pages/edit.asp",
      "method": "GET"
    },
    {
      "name":   "Edit",
      "path":   "/main/:type/{id:\\d+}/edit",
      "target": "/handlers/dev.edit",
      "method": "POST"
    },
    {
      "name":     "List",
      "path":     "/main/:type/list/{page:\\d*}",
      "target":   "/pages/list.asp",
      "method":   "*",
      "defaults": { "page": 1 }
    },
    {
      "name":   "Delete",
      "path":   "/main/:type/{id:\\d+}/delete",
      "target": "/handlers/dev.delete",
      "method": "POST"
    }
  ]
  ...
}
...

DESCRIPTION

For a gentle introduction to URL Routing in general, see Router::Generic, since ASP4x::Router uses Router::Generic to handle all the routing logic.

URL Routing is the best thing since sliced bread. Routing has been approved by the FDA to:

  • Slice!

  • Dice!

  • Do your dishes!

  • Kill mice!

URL Routing is also a cure for the poorly-constructed URL.

PREREQUISITES

ASP4, Router::Generic

AUTHOR

John Drago <jdrago_999@yahoo.com>

LICENSE

This software is Free software and may be used and redistributed under the same terms as any version of Perl itself.