Act handlers

Definition

A handler is a subroutine tied to a specific URL.

How to write handlers

Choose a suitable name space for your handler, we'll use Act::Handler::Foo. Create your handler in lib/Act/Handler/Foo.pm, naming your sub handler.

The handler subroutine

In your handler subroutine:

URL to handler dispatch

Now choose an "action" word that best describes your handler. We'll use the string foo. We now associate that action word with our sub by adding the mapping to the %public_handlers hash in Act::Dispatcher.

  my %public_handlers = (
    ...
    foo => 'Act::Handler::Foo',
    ...
  );

This will enable this handler for all URLs that start with /conference/foo where conference is a conference name, e.g.:

  /2004/foo
  /2004/foo?q=1
  /2004/foo/bar

If this action requires the user to be registered, add the mapping to %private_handlers instead:

  my %private_handlers = (
    ...
    foo => 'Act::Handler::Foo,
    ...
  );

The user will be prompted for credentials (login and password) the first time a protected page is requested in a given session.

Authors

Philippe Bruhat, Éric Cholet

License

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