Hi Juan,

It really sounds like your Reporter is your model, i.e, you can test it and use it without a web app.
The anon sub a Mojolicious::Lite route calls becomes a method (action) of a controller class.
The controller generally handles decoding the input, calls model methods in response, and formats the output.
The "view" is usually just the template, and a template is usually associated with a controller method (aka action).
It sounds like your Formatter is either part of the controller or a helper that the controller can call to render parts of the template.
Setting up the response (i.e, the content-type headers) is usually a controller responsibility.
Finally, the app just handles setup - things that need to run at startup: reading config files, setting up routes, loading plugins or helpers, etc.

- Dotan

On 04/30/2015 03:01 PM, Juan Clavero wrote:
Hi all,
I have a doubt on how to organize everything in a Mojolicious app

Right now my app is Mojolicious::Lite. It has a lib folder with two modules: a Reporter and a Formatter.
The app has only one route: 'reporter/FunctionName'. It decodes the input param from JSON, calls $Response = Reporter->FunctionName(param). If no format is chosen, it codes response to JSON and renders it. If a format is chosen (e.g. PDF or XLS), $FormattedData = Formatter->Format($Response) and renders $FormattedData.
The Reporter gathers data and calculates things. Returns a hashref with data. The Formatter grabs this hashref, fills a template with it and returns the data with proper content_disposition and content_type.

If I'd was to turn this app to Mojolicious, the current app would be the controller, the reporter would be the model and the formatter would be the view? Or app would be the controller and both reporter and formatter would be models? Or app would disappear, Reporter would be the controller and its auxiliaries and formatter would be the model?

I'm really a mess right now. Kind regards,
Juan



--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

--
You received this message because you are subscribed to the Google Groups "Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.

Reply via email to