Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Multiple routes that execute the same action

by sundialsvc4 (Abbot)
on Mar 28, 2014 at 12:33 UTC ( [id://1080080]=note: print w/replies, xml ) Need Help??


in reply to Multiple routes that execute the same action

Most of the time, the URL-matching algorithms (in any framework ...) allow you to specify regular-expressions of various sorts to specify the URLs that should invoke a particular subroutine.   And, they usually allow for a list of regexes to be associated with any particular sub.

That being said ... consider also that maybe the simplest and most obvious approach might be the best one:   specify different subroutines for each URL pattern, and have each of them gather-up whatever parameters might be in their URLs (each in their own way), and then return the result of a call to a separate, common subroutine to handle the common behavior.   To my way of thinking, this puts no real burden on the programmer, is perfectly clear, and graciously facilitates variations in the URL-layout without adding complexity or “coupling” one routine to another.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1080080]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (2)
As of 2024-04-19 21:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found