A single-file DSL for the Mojolicious web framework for the Perl language. It is just a tiny wrapper around Mojolicious, so [tag:mojolicious] may be more appropriate for questions not about the DSL itself.
Questions tagged [mojolicious-lite]
77 questions
13
votes
1 answer
How to call action in some other controller in Mojolicious?
I have an application that uses the Mojolicious framework. I have a table in the database that has a list of error response and additional details associated with it. I have created corresponding Result and Resultset to work with the DB table. There…

Ha Sh
- 724
- 5
- 26
8
votes
1 answer
Mojolicious one liner to service status files with listing directory
I am looking for Mojolicious one liner for serving static files and listing the directory by default
I come to this one liner :
perl -Mojo -E "a->static->paths(['c:\temp']);a->start" daemon
which serving static files on specific directory but its…

dave
- 867
- 1
- 5
- 11
8
votes
2 answers
How to use my own subroutines (globally) in a Mojolicious::Lite Application
I need to be able to write and call my own subroutines in a Mojolicious::Lite Application. However, the intuitive way to do this doesn't seem to be working. I emailed a colleague who has more Mojolicious experience than I do with this question and…

kingsfoil
- 3,795
- 7
- 32
- 56
7
votes
3 answers
Mojolicious lite how to redirect for not found and server error pages to user defined error page
How to redirect user defined error page for not found and server error pages to user define page Mojolicious lite

joe
- 34,529
- 29
- 100
- 137
5
votes
1 answer
How to dump all Mojolicious routes?
Full Mojolicious application have routes command which will dump application routes:
script/my_app.pl routes
How can I do same thing from testing script for Lite application?
use Mojo::Base -strict;
use Test::Mojo;
use Test::More;
use…

Eugen Konkov
- 22,193
- 17
- 108
- 158
5
votes
1 answer
Test::Mojo + prove leads to duplicate logging
I have the following test script that utilizes Test::Mojo. When I run it from the command line using perl, it outputs correctly. However, when I run it through "prove -v", the Mojo logging is duplicated and one of them isn't piped through "on…

Miller
- 34,962
- 4
- 39
- 60
5
votes
2 answers
How to create common handler for all incoming URLs?
I'm in process of writing some web api, which returns data in JSON format.
For all incoming urls i need to return some result from cache if cache period doesnt expire.
This logic is universal for all URLs.
Question:
How to implement some common…

drvtiny
- 705
- 3
- 13
4
votes
1 answer
how to manage myself SIGINT and SIGTERM signals?
I am working on a simple Mojolicious::Lite based server that includes a websocket end point.
I would like to handle some termination signals to terminate gracefully the websocket connections and avoid exceptions in the clients (a java…

Seki
- 11,135
- 7
- 46
- 70
4
votes
2 answers
Do something after rendering in mojolicious
How can I make my code do something after HypnoToad sends a page? (Note: I am answering my own question. I am posting this, because StackOverflow pointed me to a previous question that did not directly solve my problem, although it did contain the…

Arnold Cross
- 199
- 1
- 12
4
votes
0 answers
How to disable caching in Mojolicious::Lite app
currently i added this line to Mojolicious::Lite app to disable caching
app->renderer->cache->max_keys(0);
but sometimes webpage showing updated content and sometimes showing cached template
i do not know exactly what the problem is, there is no…

rx57
- 189
- 1
- 5
4
votes
3 answers
How to enable "pretty" JSON rendering in Mojolicious::Lite?
Simple question. How do I turn on "pretty" json rendering in Mojolicious::Lite? I'm developing a RESTful API and would like to see my output in a bit more human readable format.

Aurelia Peters
- 2,169
- 1
- 20
- 34
3
votes
3 answers
How to change Mojolicious Lite default error not found to a custom json response
I'm creating a json web service using Mojolicious Lite.
By default Mojolicious returns a HTML response for a server error or not found error.
Is there a way to overwrite this to a custom JSON response?

Franco
- 57
- 1
- 6
3
votes
1 answer
Delayed response to slash command with Mojolicious in Perl
I am trying to create a slack application in Perl with mojolicious and I am having the following use case:
Slack sends a request to my API from a slash command and needs a response in a 3 seconds timeframe. However, Slack also gives me the…

Spyratos Aggelos
- 91
- 1
- 7
3
votes
1 answer
A log file isn't getting created and written into in my Mojolicious app
I have this in my Mojolicious app:
use utf8;
use Mojolicious::Lite;
# ......
use Mojo::Log;
my $app = app;
my $log = Mojo::Log->new(path => '/var/log/my_log.log', level => 'warn');
get '/' => sub {
.........
…

Ojman
- 51
- 4
3
votes
1 answer
Mojolicious Parameter Validation
I have the following code :
get '/:foo' => sub {
my $c = shift;
my $v = $c->validation;
my $foo = $c->param('y');
$c->render(text => "Hello from $foo.") if $v->required('y')->like(q/[A-Z]/);
};
and want to verify the y parameter of…

smith
- 3,232
- 26
- 55