Re: about request route

Lathan Bidwell <[email protected]>
Newsgroups gmane.comp.apache.mod-perl
Message-ID <CAOqPvqhfeyDhuejpoDYD31rZUtY3E7kwbS+DH59S6hcVzvpEqw@mail.gmail.com>
Hello,

MP does not by default include a routing engine like Dancer or Mojo or
other frameworks.

There are routing engines available (but I'm not very familair with them).

For a pure MP option, see this example from something I've done:

$base_uri = "/app/"
uri = /app/type/AAAA/domain/dns-api.org/



   my $uri = $r->uri();
>                 # Remove the base uri from the uri
>                 $uri =~ s/^$base_uri//g;
>                 # Split the components out by '/'
>                 my @components = split(/\//, $uri);
>          # Take all the components and make the odd ones the names and the
> even ones
>          # the values in the CGI query object
>                 while (@components)
>                         {
>                         $components[1] =~ s/\|/\//g;
>                         $q->param(-name => shift(@components), -value =>
> shift(@components));
>                         }
>                 }



*Lathan Bidwell*

Web Programmer
Division of Integrated Marketing & Communication
Andrews University

269-471-6313
*office*www.andrews.edu

"Seek Knowledge.  Affirm Faith.  Change the World."



On Mon, Aug 7, 2017 at 7:18 AM, 风河 <[email protected]> wrote:

> Hi,
>
> for this like request:
> curl http://dns-api.org/AAAA/dns-api.org
>
> in Dancer we could write:
>
> get '/:type/:domain/?' => sub {
>
>     my $rtype  = params->{ 'type' };
>     my $domain = params->{ 'domain' };
>
>
> But in a MP handler, how could we get the similiar result, treating
> request path as GET/POST arguments?
>
> thanks.
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.