Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

Re: Mojo app running IIS CGI

by Anonymous Monk
on Feb 11, 2021 at 16:33 UTC ( #11128231=note: print w/replies, xml ) Need Help??

in reply to Mojo app running IIS CGI

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re^2: Mojo app running IIS CGI
by WookieeJeff (Initiate) on Feb 11, 2021 at 16:55 UTC
    It is either before any CGI CPAN modules or the author chose not to use them. A lot of the code revolves around manual print statements and hand-coded headers. Thus the effort to rebuild parts of it in Mojo, which seems like a great choice for a modern website. I'm just having trouble with running CGI mode and IIS.

      If I understand it right, you have multi-directory application with many scripts in them. If that is so, then every directory that your CGI application have will become Mojolicious::Controller, every script will become URL, and all logic will go to appropriate Controller.

      If you have something like this in your application directory:

      .. dir1/somescript1 dir1/somescript2 dir2/somescript3 dir3/somescript4
      then your Mojolicious application will have something like this inside:
      script/ lib/ lib/App/Controller/ lib/App/Controller/ lib/App/Controller/ templates/layouts/default.html.ep templates/main/index.html.ep
      #!perl use strict; use warnings; use FindBin; BEGIN { unshift @INC, "$FindBin::Bin/../lib" } use Mojolicious::Commands; Mojolicious::Commands->start_app('App');
      package App; use Mojo::Base 'Mojolicious'; sub startup { my $self = shift; my $r = $self->routes; $r->get('/')->to('main#index'); $r->get('/dir1/somescript1')->to('dir1#somescript1'); $r->get('/dir1/somescript2')->to('dir1#somescript2'); $r->get('/dir2/somescript3')->to('dir2#somescript3'); $r->get('/dir2/somescript4')->to('dir2#somescript4'); } 1;
      package App::Controller::Main; use Mojo::Base 'Mojolicious::Controller'; sub index { my $self = shift; # will render templates/main/index.html.ep # logic from $self->render(); } 1;
      package App::Controller::Dir1; use Mojo::Base 'Mojolicious::Controller'; sub somescript1 { my $self = shift; my $params = $self->req->params->to_hash; # logic from dir1/ # all HTML goes to templates/dir1/somescript1.html.ep $self->render(); } # etc... 1;
      Then you run it from root of your application like this:
      perl script/
      update: I thought that you might want to read the docs: Mojolicious Tutorial, Growing Guide

      Actually, what I'd like to do is have a central Mojo CGI script and route URLs appropriately to Perl Controllers. So a single file receiving all the various web requests, let's name it for the sake of discussion. The routing would work as follows:* - Legacy traffic* - Anything in this subdirectory runs, which routes them accordingly

      The problem I'm running into is that when running in CGI mode, the URL parameter Mojo detects is always /. For example /mojo/foo and /mojo/bar both get detected in CGI mode as /

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (4)
As of 2021-05-07 17:42 GMT
Find Nodes?
    Voting Booth?
    Perl 7 will be out ...

    Results (93 votes). Check out past polls.