s136222 has asked for the wisdom of the Perl Monks concerning the following question:

Dear Monks:

I have a number of standalone scripts that have been running quite nicely for the past six months. They have been running so well that other folks from other internal networks want to use those scripts and call them as REST services from their machines across our internal networks.

The scripts are of the format:

./foo.pl -x arg1 -y arg2 ...

./bar.pl -z arg3 -w arg4 ...

and on and on.

The scripts don't return anything; only a status that they were successfully launched, or a usage statement if the input args are not correct.

I'm reading a lot about "mojolicious". What is the most expeditious way to re-tool these scripts, that work quite well, into REST services using something like Mojolicious? What I'd like to see is an example. The Mojolicious docs are very comprehensive, but a simple example of what I'm trying to do isn't jumping out at me.

Thanks for considering.

Replies are listed 'Best First'.
Re: Converting to REST
by davido (Cardinal) on Oct 01, 2012 at 04:37 UTC

    If it's not too much work to do so, I would turn each of your applications into thin wrappers that drive a module that embodies all the "business logic". Then the modules could be used without your application wrappers, as the models for your Mojolicious::Lite application. The Mojolicious::Lite app would drive the two modules based on whatever RESTful API you cook up. This avoids the level of paranoia that has to go in to invoking system commands using arguments passed from a web application.


    Dave