NAME

Dancer::Plugin::Legacy::Routing - Dancer Plugin for Deprecating Existing Routes

SYNOPSIS

package MyDancerApp;

use strict;
use warnings;

use Dancer;
use Dancer::Plugin::Legacy::Routing;

get        "/my/fancy/new/route"  => \&still_good_controller;
legacy_get "/my/stinky/old/route" => \&still_good_controller;

sub still_good_controller {
  status 200;
  return "Plugins Rocks!";
}

DESCRIPTION

Often times in refactoring and general software development of web applications a developer will find themselves with the need to support all existing routes while at the same time building out a better set of routes. The major problem here is to find all applications, templates, bookmarks, and all other references to these old routes, that is not always possible.

Enter Dancer::Plugin::Legacy::Routing, this plugin for Dancer allows you to clean up and improve all of your routes while still maintaining all of your old ones in a clean and easy to see and understand way. You can even optionally get log entries that will tell you how people are getting to your old routes and how often they are being called.

Configuration

Dancer::Plugin::Legacy::Routing makes use of the standard Dancer environment based routing. Since this is a plugin, be sure to include this is the correct place under plugins.

Options

log

Currently "log" is the only option (this will likely be built out in future versions). Having this set to a truthy value will result in messages being written (with the level of info) to your dancer log file.

[30494]  info @0.000631> [hit #2]Legacy Route GET '/legacy/get' referred from '(none)' in repos/Dancer-Plugin-Legacy-Routing/lib/Dancer/Plugin/Legacy/Routing.pm l. 32

YAML Example Configuration File

logger: file
log: info
warnings: 1
show_errors: 1
auto_reload: 0

plugins:
  Legacy::Routing:
    log: 1

NOTE The name of this plugin is Legacy::Routing, that is what you want to specify in your environment's configuration file.

METHODS

The standard HTTP methods are available for you to legacy-ify, including any.

legacy_get

get "/good/get"          => \&test_get;
legacy_get "/legacy/get" => \&test_get;

get "/good/get/:var"          => \&test_get_with_var;
legacy_get "/legacy/get/:var" => \&test_get_with_var;

get "/good/get/:var/params"          => \&test_get_with_params;
legacy_get "/legacy/get/:var/params" => \&test_get_with_params;

legacy_post

post "/good/post"          => \&test_post;
legacy_post "/legacy/post" => \&test_post;

post "/good/post/:var"          => \&test_post_with_var;
legacy_post "/legacy/post/:var" => \&test_post_with_var;

post "/good/post/:var/params"          => \&test_post_with_params;
legacy_post "/legacy/post/:var/params" => \&test_post_with_params;

legacy_put

put "/good/put"          => \&test_put;
legacy_put "/legacy/put" => \&test_put;

put "/good/put/:var"          => \&test_put_with_var;
legacy_put "/legacy/put/:var" => \&test_put_with_var;

put "/good/put/:var/params"          => \&test_put_with_params;
legacy_put "/legacy/put/:var/params" => \&test_put_with_params;

legacy_del

del "/good/delete"          => \&test_del;
legacy_del "/legacy/delete" => \&test_del;

del "/good/delete/:var"          => \&test_del_with_var;
legacy_del "/legacy/delete/:var" => \&test_del_with_var;

del "/good/delete/:var/params"          => \&test_del_with_params;
legacy_del "/legacy/delete/:var/params" => \&test_del_with_params;

legacy_any

any "/good/any"          => \&test_any;
legacy_any "/legacy/any" => \&test_any;

AUTHORS

Robert Stone <drzigman AT cpan DOT org >

COPYRIGHT & LICENSE

Copyright 2014 Robert Stone

This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU Lesser General Public License as published by the Free Software Foundation; or any compatible license.

See http://dev.perl.org/licenses/ for more information.