I started looking for alternatives for cleaning up my web application URLs, and found CGI::Application::Dispatch. Except, I can't, for the life of me, figure out how to graft in C::A::D into my existing application.

Update: Added words in emphasis to the above para. Without them the sentence didn't make any sense.

Here is the background --

I have a reasonably mainstream application made with CGI::Application and a sprinkling of Plugins (DBH, Session, LogDispatch, AutoRunmode).

I follow the usual pattern --

package Myapp; use base 'CGI::Application'; use CGI::Application::Plugin::* sub view : StartRunmode {} sub edit : Runmode {} sub update : Runmode {} sub create : Runmode {} sub save : Runmode {} sub find : Runmode {} .. bunch of supporting subs .. sub setup {} sub cgiapp_get_query { .. require CGI::Simple; } sub cgiapp_init { }

Everything works, and now I want to clean up my URLs. Nothing fancy, just the usual stuff like so --

<server> --> <server>/index.cgi <server>/ --> <server>/index.cgi <server>/Item --> <server>/index.cgi?rm=view&id=Item <server>/(view|edit|create)/Item --> <server>/index.cgi?rm=$1&id=Item <server>/find/?q=search_term --> <server>/index.cgi?rm=find&q=search_t +erm

calls to "update" and "save" will be via POST, so they should be let in freely, and the same applies to all static content such as css, js, media, etc.

So, I started with mod_rewrite voodoo, but after 4 days of tackling it unsuccessfully, I have given up on it.

Even if I get everything working well with mod_rewrite, I am actually loathe to implement it, because in the long run, I want to do minimum amount of messing with Apache configs, something I may not have complete control over in different conditions. Keep in mind, I don't mind implement a couple of mod_rewrite rules, but doing it in my application will give me more control for future development and modification.

So, I started looking for alternatives, and found CGI::Application::Dispatch. Except, I can't, for the life of me, figure out how to graft in C::A::D into my existing application.

If I am being dense, just whack me on your head with your esc key. In any case, do guide me through this valley of confusion.

Once I figure it all out, I will write up a nice easy tutorial that even PHP folks will be able to understand. Promise.

Update: and, yes, I have looked at all the CGI::App::Dispatch articles that I could find. While they do explain stuff, they don't explain it in context of implementing CAD within and existing CGI::App application. At least, not in the way I could understand.

Update2: and, I need to do with vanilla cgi first, before I attempt all the CAD magic with mod_perl

--

when small people start casting long shadows, it is time to go to bed

In reply to using CGI::Application::Dispatch in my existing application by punkish

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.